判斷一個年份是不是閏年
閏年就是能被4整除并且不能被100整除,或者能被400整除。
#define _CRT_SECURE_NO_WARNINGS 1
#include<string.h>
#include<stdio.h>
#include<iostream>
#include<math.h>
int is_leap(int year)
{
if ((year % 4 == 0) && (year % 100 != 0) == 1)
return 0;
else if (year % 400 == 0)
return 0;
else
return -1;
}
int main()
{
int year = 0;
scanf("%d", &year);
int a = is_leap(year);
if (a == 0)
printf("是閏年\n");
else
printf("不是閏年\n");
system("pause");
return 0;
}