Run ID | Author | Problem | Lang | Verdict | Time | Memory | Code Length | Submit Time |
---|---|---|---|---|---|---|---|---|
48905 | fuhaoze | 展示闰年 | C++ | Accepted | 0 MS | 252 KB | 600 | 2024-06-15 12:20:49 |
#include <bits/stdc++.h> using namespace std; bool leap(int y) { if(y % 4 == 0 && y % 100 != 0 || y % 400 == 0) { return true; } return false; } bool leap1(int y) { if(y % 100 == 0) { if(y % 400 == 0) return true; else return false; }else { if(y % 4 == 0) return true; else return false; } } int main() { int x, y, cnt = 0; cin >> x >> y; int year[3010]; for (int i = x; i <= y; i++) { if(leap1(i) == true) { cnt++; year[cnt] = i; } } cout << cnt << endl; for (int i = 1; i <= cnt; i++) { cout << year[i] << " "; } return 0; }