在Dev-C++情况下编译的程序,不知道哪里错了

[复制链接]
查看11 | 回复2 | 2010-12-6 19:52:32 | 显示全部楼层 |阅读模式
#include
#include
void main()
{

int a,b;

int days[2][12]={{31,28,31,30,31,30,31,31,30,31,30,31},{31,29,31,30,31,30,31,31,30,31,30,31}};

int isleapyear(int year);

printf("请输入年份:\n");

scanf("%d\n",&a);

printf("请输入月份:\n");

scanf("%d\n",&b);

if ((b12))

printf("你输入的月份有误\n");

else

printf("您输入的年份为%d月份为%d该月有%d天\n",a,b,days[isleapyear(a)][b-1]);

system("pause");
}

int isleapyear(int a);

{

if (((a%400==0)&&(a%4==0))||(a&100!=0))

return 1;

else

return 0;

}
哪里出错了?

回复

使用道具 举报

千问 | 2010-12-6 19:52:32 | 显示全部楼层
isleapyear函数在main函数外定义,并且函数说明后多了分号,闰年计算不对,scanf函数中不用换行。
回复

使用道具 举报

千问 | 2010-12-6 19:52:32 | 显示全部楼层
函数isleapyear的定义应该放在main前面
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行