system("mode con cols=40 lines=25");表示运行显示框的大小;
while (~scanf("%d", &year))表示实现多组输入;
getchar();表示消除“/n”回车符号带来的影响。
#include <stdio.h>
IsLeapYear(int year)
{
int a;
if ((year % 4 == 0) && (year % 100 != 0) || (year % 400 == 0))
a = year;
else
a = -1;
return a;
}
int main()
{
system("mode con cols=40 lines=25");
int year;
while (~scanf("%d", &year))
{
getchar();
if (IsLeapYear(year) != -1)
printf("%d是闰年\n", year);
else
printf("%d不是闰年\n", year);
}
return 0;
}