解题思路:switch累加
注意事项:重复使用:while(scanf("%d/%d/%d",&year,&month,&day)!=EOF){ 算法代码 }
参考代码:
#include <stdio.h> int main() { int year,month,day,total; while(scanf("%d/%d/%d",&year,&month,&day)!=EOF) { 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分
2 人评分
不容易系列 (C语言代码)浏览:669 |
多输入输出练习1 (C语言代码)浏览:1189 |
ASCII帮了大忙浏览:749 |
字符逆序 (C语言代码)浏览:646 |
C语言程序设计教程(第三版)课后习题5.6 (C语言代码)浏览:534 |
简单的a+b (C语言代码)浏览:419 |
2004年秋浙江省计算机等级考试二级C 编程题(1) (C语言代码)浏览:600 |
C语言程序设计教程(第三版)课后习题9.6 (C语言代码)浏览:588 |
C语言程序设计教程(第三版)课后习题10.3 (C语言代码)浏览:509 |
陈教主的三角形 (C语言代码)浏览:1143 |