C语言-闰年判断

#include<stdio.h>
int main()
{
    
    
    //四年一润 , 百年不润 ,四百年再润
	
	//闰年:有两种情况:  1、可以被4整除 ,但是不能被100整除
						//2、可以被400		
	int  years;
	scanf("%d" , &years);
	if((0 == years % 4 && 0 != years % 100) || 0 == years % 400)
	{
    
    
		printf("闰年\n");
	}
	else
	{
    
    
		printf("不是闰年\n");
	}
}

猜你喜欢

转载自blog.csdn.net/qq_40843903/article/details/112253323
今日推荐