回复 9楼 laoyang103
好的丶我昨天给他改了丶应该在输入那加一个while控制输入多组数据应该就好了丶
编程之路定要走完……
#include<stdio.h> int main()/*你这个括号不是半角字符*/ { int day,month,year,a; int sum1(int m); int sum2(int m); while(scanf("%d/%d/%d",&year,&month,&day)!=EOF)/*这里你把year和day调一下人们习惯输入年月日*/ { if(year%10!=0&&year%4==0||year%400==0)/*判断闰年要注意*/ a=sum1(month); else a=sum2(month); printf("%d\n",a+day); } return 0;/*这里返回一个值规范编程*/ } int sum1(int m) { int x;/*虽然这里是局部变量但为了让你思路清晰换成x*/ switch(m-1)/*你要不减一的话输出就多了一个月,还有不可以a=awitch*/ { case 0:x=0;break;/*一月分时候输出下面的和这个一样,并给相应的x赋值*/ case 1:x=31;break; case 2:x=60;break; case 3:x=91;break; case 4:x=121;break; case 5:x=152;break; case 6:x=182;break; case 7:x=213;break; case 8:x=244;break; case 9:x=274;break; case 10:x=305;break; case 11:x=335;break; case 12:x=366;break; } return (x); } int sum2(int m) { int x; switch(m-1) { case 0:x=0;break; case 1:x=31;break; case 2:x=59;break; case 3:x=90;break; case 4:x=120;break; case 5:x=151;break; case 6:x=181;break; case 7:x=212;break; case 8:x=243;break; case 9:x=273;break; case 10:x=304;break; case 11:x=334;break; case 12:x=365;break; } return (x); }
#include <stdio.h> int ping[] = {0,31,28,31,30,31,30,31,31,30,31,30,31}; int run[] = {0,31,29,31,30,31,30,31,31,30,31,30,31}; bool f(int year) { if(year % 4 == 0 && year % 100 != 0 || year % 400 == 0) return true; return false; } int main() { int m,n,s; int i,j; while(EOF != scanf("%d/%d/%d",&m,&n,&s)) { if(f(m)) for(j = 0,i = 1;i<n;i++) j += run[i]; else for(j = 0,i = 1;i<n;i++) j += ping[i]; printf("%d\n",j+s); } return 0; }