问题描述
- C语言求大家解答,怎么改都出错
-
#include
#include
#define MONTHS 12
int main()
{
int years,month,ret,day,a,math=0;
printf("Input:");
int days[2][MONTHS]={{31,28,31,30,31,30,31,31,30,31,30,31},{31,29,31,30,31,30,31,31,30,31,30,31}};
ret=scanf("%d/%d/%d",&years,&month,&day);
while((ret!=1)||month12)
{
while(getchar()!='n');
ret=scanf("%d/%d/%d",&years,&month,&day);
}
if(month==1)
{
math=day;
}
else
{
math=day;
if(((years%4==0)&&(years%100!=0))||(years%400==0))
{
for(a=1;a<month;a++)
{
math=days[0][month-a-1]+math;
}
}
else
{
for(a=1;a<month;a++)
{
math=days[1][month-a-1]+math;
}
}
printf("%d",math);
return 0;
}
程序一直报错 expected declaration or statement at end of input
都要疯了求解答
解决方案
if(month==1)
{
math=day;
}
else
{
math=day;
这一个else少了个右花括号
时间: 2024-10-07 18:01:52