解题思路:比输入版判断日子简单,只需要初始化year、month、day,直接计算total
注意事项:闰年&&月份>2 才+1
参考代码:
#include <stdio.h> int main() { int year=2018,month=7,day=19,total=0; total+=day; switch(month-1) { case 11: total+=30; case 10: total+=31; case 9: total+=30; case 8: total+=31; case 7: total+=31; case 6: total+=30; case 5: total+=31; case 4: total+=30; case 3: total+=31; case 2: total+=28; case 1: total+=31; } if(year%400==0||year%4==0&&year%100!=0) if(month>2) total++; printf("%d\n",total); }
0.0分
0 人评分