c语言问题
我自己写的一个计算一年中某一天在该年是第几天:#include<stdio.h>
void main()
{
int y,m,d,total=0;
printf("please input y空格m空格d:");
scanf("y/m/d=%d%d%d",&y,&m,&d);
if(m==1)
printf("total=%d",d);
if(m==2)
printf("total=%d",d+31);
if(m==3)
{
if(y%4==0&&(y%100!=0)||y%400==0)
printf("total=%d",d+31+29);
else
printf("total=%d",d+31+28);
}
if(m==4)
{
if(y%4==0&&y%100!=0||y%400==0)
printf("total=%d",d+31+29+31);
else
printf("total=%d",d+31+28+31);
}
if(m==5)
{
if(y%4==0&&y%100!=0||y%400==0)
printf("total=%d",d+31+29+31+30);
else
printf("total=%d",d+31+28+31+30);
}
if(m==6)
{
if(y%4==0&&y%100!=0||y%400==0)
printf("total=%d",d+31+29+31+30+31);
else
printf("total=%d",d+31+28+31+30+31);
}
if(m==7)
{
if(y%4==0&&y%100!=0||y%400==0)
printf("total=%d",d+31+29+31+30+31+30);
else
printf("total=%d",d+31+28+31+30+31+30);
}
if(m==8)
{
if(y%4==0&&y%100!=0||y%400==0)
printf("total=%d",d+31+29+31+30+31+30+31);
else
printf("total=%d",d+31+28+31+30+31+30+31);
}
if(m==9)
{
if(y%4==0&&y%100!=0||y%400==0)
printf("total=%d",d+31+29+31+30+31+30+31+31);
else
printf("total=%d",d+31+28+31+30+31+30+31+31);
}
if(m==10)
{
if(y%4==0&&y%100!=0||y%400==0)
printf("total=%d",d+31+29+31+30+31+30+31+31+30);
else
printf("total=%d",d+31+28+31+30+31+30+31+31+30);
}
if(m==11)
{
if(y%4==0&&y%100!=0||y%400==0)
printf("total=%d",d+31+29+31+30+31+30+31+31+30+31);
else
printf("total=%d",d+31+28+31+30+31+30+31+31+30+31);
}
if(m==12)
{
if(y%4==0&&y%100!=0||y%400==0)
printf("total=%d",d+31+29+31+30+31+30+31+31+30+31+30);
else
printf("total=%d",d+31+28+31+30+31+30+31+31+30+31+30);
}
}