求各位大佬帮我看一下这个C语言程序哪里错了,谢谢
#include<stdio.h>intmain(){intday,month,year,sum,leap,fin;printf("请输入年月日:");scanf("%l...
#include<stdio.h>
int main()
{int day,month,year,sum,leap,fin;
printf("请输入年月日:");
scanf("%ld,%ld,%ld",&year,&month,&day);
if(month>0)
{
if(month==1)
sum=0;
else if(month==2)
sum=31;
else if(month==3)
sum=59;
else if(month==4)
sum=90;
else if(month==5)
sum=120;
else if(month==6)
sum=151;
else if(month==7)
sum=181;
else if(month==8)
sum=212;
else if(month==9)
sum=243;
else if(month==10)
sum=273;
else if(month==11)
sum=304;
else if(month==12)
sum=334;
else
printf("输入错误,请重新输入。");
}
else
printf("输入错误,请重新输入。");
fin=sum+day;
if(year%400==0||(year%4==0&&year%100!=0))
leap=1;
else
leap=0;
if(leap==1&&month>2)
fin++;
printf("这是%ld年的第%ld天。",year,fin);
return 0;
} 展开
int main()
{int day,month,year,sum,leap,fin;
printf("请输入年月日:");
scanf("%ld,%ld,%ld",&year,&month,&day);
if(month>0)
{
if(month==1)
sum=0;
else if(month==2)
sum=31;
else if(month==3)
sum=59;
else if(month==4)
sum=90;
else if(month==5)
sum=120;
else if(month==6)
sum=151;
else if(month==7)
sum=181;
else if(month==8)
sum=212;
else if(month==9)
sum=243;
else if(month==10)
sum=273;
else if(month==11)
sum=304;
else if(month==12)
sum=334;
else
printf("输入错误,请重新输入。");
}
else
printf("输入错误,请重新输入。");
fin=sum+day;
if(year%400==0||(year%4==0&&year%100!=0))
leap=1;
else
leap=0;
if(leap==1&&month>2)
fin++;
printf("这是%ld年的第%ld天。",year,fin);
return 0;
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询