提交时间:2024-06-15 12:20:49

运行 ID: 48905

#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; }