Error prone:
1. The stream operation will time out! Only scanf and printf can be used.
Description:
Input a certain year, please write a program to determine whether the year is a leap year.
Input:
The input contains multiple sets of data, and each set of data includes a positive integer Y.
Output:
For each set of test data, if the year is a leap year, output "Leap Year", otherwise output "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;
}