C语言程序设计-谭浩强

用条件语句嵌套判断是否是闰年

#include<stdio.h>
int main()
{
int year, test;
scanf("%d", &year);
if (year % 4 == 0)
{
if (year % 100 == 0)
{
if (year % 400 == 0)
test = 1;
else
test = 0;
}
else
test = 1;
}
else
test = 0;

if (test)
printf("%d 是闰年\n", year);
else
printf("%d 不是闰年\n", year);

return 0;
}

posted @ 2020-03-12 15:20  新生代农民工  阅读(318)  评论(0)    收藏  举报