判断year年份是否为闰年(能被4整除是闰年,能被整除100不是,能被400整除是闰年)。闰年leap_year为1,否则为0.

/*判断year年份是否为闰年(能被4整除是闰年,能被整除100不是,能被400整除是闰年)*/
#include
#include


void main()
{
int year,leap_year;
scanf("%d",&year);
if(year%400==0)
{
leap_year=1;
printf("%d is 闰年",year);
}
else if(year%100==0)
{
   leap_year=0;
printf("%d is not 闰年",year);
}
else if(year%4==0)
{
leap_year=1;
printf("%d is 闰年",year);
}
else 
{
leap_year=0;
printf("%d is not 闰年",year);
}

}

你可能感兴趣的:(c和指针)