实现一个函数判断year是不是闰年。

来源:互联网 发布:五金进销存软件 编辑:程序博客网 时间:2024/06/06 02:50

#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>

#include <stdlib.h>

int runnian(int i)

{

return(((i % 4 == 0) && (i % 100 != 0)) || (i % 400 == 0));

}

int main()  

{

int i = 0;

printf("请输入要判断的年份");

scanf("%d", &i);

if (runnian(i))

printf("%d是闰年", i);

else

printf("%d不是闰年",i);

getchar();

system("pause");

    return 0;  

}