【題目敘述】https://zerojudge.tw/ShowProblem?problemid=d069
#include <iostream>
using namespace std;
int main() {
int t;
cin >> t;
for (int i = 0; i < t; i++) {
int y;
cin >> y;
if (((y % 4 == 0) && (y % 100 != 0)) || (y % 400 == 0))
cout << "a leap year\n";
else
cout << "a normal year\n";
}
return 0;
}
Python code (credit: Amy Chou)
t = int(input())
for _ in range(t):
y = int(input())
if ((y % 4 == 0) and (y % 100 != 0)) or (y % 400 == 0):
print("a leap year")
else:
print("a normal year")
import sys
lines = sys.stdin.readlines()
t = int(lines[0])
for i in range(1, t+1):
y = int(lines[i])
if ((y % 4 == 0) and (y % 100 != 0)) or (y % 400 == 0):
print("a leap year")
else:
print("a normal year")