易错:
1、流操作会超时!只能用scanf、printf。
Description:
输入某一年份,请编写程序判断该年是否为闰年。
Input:
输入有多组数据,每组数据包括一个正整数Y。
Output:
对于每组测试数据,如果该年是闰年,输出“Leap Year”,否则输出“Not Leap Year”。
Sample Input:
1989
2000
Sample Output:
Not Leap Year
Leap Year
#include<iostream>
using namespace std;
int main() {
int year;
while (scanf("%d", &year) != EOF) {
if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) {
printf("Leap Year\n");
} else {
printf("Not Leap Year\n");
}
}
return 0;
}