未运用结构体
#include struct Date{ int nian; int yue; int ri; }; int main() { int a=0,m,n,i,j; scanf("%d%d%d",&m,&n,&i); if(m%4==0&&m||m%400==0) { switch(n-1){ case 12:a+=31; case 11:a+=30; case 10:a+=31; case 9:a+=30; case 8:a+=31; case 7:a+=31; case 6:a+=30; case 5:a+=31; case 4:a+=30; case 3:a+=31; case 2:a+=29; case 1:a+=31; default:a+=0; } } else{ switch(n-1){ case 12:a+=31; case 11:a+=30; case 10:a+=31; case 9:a+=30; case 8:a+=31; case 7:a+=31; case 6:a+=30; case 5:a+=31; case 4:a+=30; case 3:a+=31; case 2:a+=28; case 1:a+=31; default:a+=0; }} printf("%d",a+i); }
运用结构体
#include<stdio.h> struct Date { int nian; int yue; int ri; }; int main() { struct Date a; int t[12]={31,28,31,30,31,30,31,31,30,31,30,31}; int i,sum=0; scanf("%d%d%d",&a.nian,&a.yue,&a.ri); if((a.nian%4==0&&a.nian%100!=0)||(a.nian%400==0)) t[1]=29; for(i=0;i<a.yue-1;i++) { sum+=t[i]; } sum+=a.ri; printf("%d",sum); return 0; }
0.0分
1 人评分
1118(求助_已解决)浏览:351 |
2005年春浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:636 |
勾股数 (C语言代码)浏览:830 |
C语言程序设计教程(第三版)课后习题7.3 (C语言代码)浏览:420 |
10月月赛题解浏览:554 |
C语言程序设计教程(第三版)课后习题11.3 (C语言代码)浏览:2207 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:527 |
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:801 |
用筛法求之N内的素数。 (C语言代码) 详解………………浏览:1194 |
哥德巴赫曾猜测 (C++代码)浏览:788 |