新手求助
#include <stdio.h>int x(int c)
{
int a;
switch (c)
{ case 1:a=0;break;
case 2:a=31;break;
case 3:a=31+28;break;
case 4:a=31+28+31;break;
case 5:a=31+28+31+30;break;
case 6:a=31+28+31+30+31;break;
case 7:a=31+28+31+30+31+30;break;
case 8:a=31+28+31+30+31+30+31;break;
case 9:a=31+28+31+30+31+30+31+31;break;
case 10:a=31+28+31+30+31+30+31+31+30;break;
case 11:a=31+28+31+30+31+30+31+31+30+31;break;
default:a=31+28+31+30+31+30+31+31+30+31+30;break;
}
return(a);
}
void main()
{
int m(int m);
int y,m,d;
printf("输入年月日\n");
scanf("%d%d%d",&y,&m,&d);
if((y%400==0||(y%4==0&&y%100!=0)&&m>2)
d=d+x(m)+1;
else d=d+x(m);
printf("这一年的第%d天\n",d);
}
输入某年某月某日,判断这一天是这一年的第几天
谁能告诉我错在哪里?
谢谢