解题思路:比输入版判断日子简单,只需要初始化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 人评分
C语言训练-排序问题<1> (C语言代码)浏览:1348 |
C语言程序设计教程(第三版)课后习题10.4 (C语言代码)浏览:879 |
【计算直线的交点数】 (C语言代码)浏览:1442 |
母牛的故事 (C语言代码)浏览:549 |
C语言程序设计教程(第三版)课后习题10.3 (C语言代码)浏览:1909 |
C语言程序设计教程(第三版)课后习题11.3 (C语言代码)浏览:564 |
2006年春浙江省计算机等级考试二级C 编程题(1) (C语言代码)浏览:661 |
川哥的吩咐 (C语言代码)浏览:609 |
输出九九乘法表 (C语言代码)浏览:1048 |
C语言程序设计教程(第三版)课后习题10.5 (C语言代码)浏览:946 |