1 条题解
-
0
C :
#include<stdio.h> struct datetime {int year; int month; int day; }; int days(struct datetime date); int main() { int count_day; struct datetime date; printf("请输入日期\n"); scanf("%d %d %d",&date.year,&date.month,&date.day); count_day=days(date); printf("日期%d/%d/%d是%d年的第%d天\n",date.year,date.month,date.day,date.year,count_day); return 0; } int days(struct datetime date) { int result=0; int year=date.year,month=date.month,day=date.day; if(month>1) { switch(month-1) { case 12: result+=31; case 11: result+=30; case 10: result+=31; case 9: result+=30; case 8: result+=31; case 7: result+=31; case 6: result+=30; case 5: result+=31; case 4: result+=30; case 3: result+=31; case 2: { if(year%400==0||year%100!=0&&year%4==0)result+=29; else result+=28; } case 1: result+=31; } result+=day; } else result=day; return result ; }
- 1
信息
- ID
- 3015
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- (无)
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者