参考代码:
#include<stdio.h> struct { int year; int month; int day; }a; int main() { int sum; scanf("%d",&a.year); scanf("%d",&a.month); scanf("%d",&a.day); if(a.year%400==0||a.year%4==0&&a.year%100!=0) { switch(a.month) { case 1:sum=0;break; case 2:sum=31;break; case 3:sum=31+29;break; case 4:sum=31+29+31;break; case 5:sum=31+29+31+30;break; case 6:sum=31+29+31+30+31;break; case 7:sum=31+29+31+30+31+30;break; case 8:sum=31+29+31+30+31+30+31;break; case 9:sum=31+29+31+30+31+30+31+31;break; case 10:sum=31+29+31+30+31+30+31+31+30;break; case 11:sum=31+29+31+30+31+30+31+31+30+31;break; case 12:sum=31+29+31+30+31+30+31+31+30+31+30;break; } } else { switch(a.month) { case 1:sum=0;break; case 2:sum=31;break; case 3:sum=31+28;break; case 4:sum=31+28+31;break; case 5:sum=31+28+31+30;break; case 6:sum=31+28+31+30+31;break; case 7:sum=31+28+31+30+31+30;break; case 8:sum=31+28+31+30+31+30+31;break; case 9:sum=31+28+31+30+31+30+31+31;break; case 10:sum=31+28+31+30+31+30+31+31+30;break; case 11:sum=31+28+31+30+31+30+31+31+30+31;break; case 12:sum=31+28+31+30+31+30+31+31+30+31+30;break; } } printf("%d\n",sum+a.day); return 0; }
0.0分
0 人评分
时间转换 (Java代码)浏览:617 |
C语言训练-求s=a+aa+aaa+aaaa+aa...a的值 (C语言代码)浏览:1084 |
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:631 |
C语言程序设计教程(第三版)课后习题6.2 (C语言代码)浏览:1432 |
C语言程序设计教程(第三版)课后习题7.5 (C语言代码)浏览:900 |
C语言程序设计教程(第三版)课后习题6.3 (C++代码)浏览:1067 |
C语言考试练习题_一元二次方程 (C语言代码)浏览:606 |
C语言训练-亲密数 (C语言代码)浏览:697 |
震宇大神的杀毒软件 (C语言代码)浏览:1162 |
C语言程序设计教程(第三版)课后习题12.2 (C语言代码)浏览:839 |