Run ID 作者 问题 语言 测评结果 时间 内存 代码长度 提交时间
42599 huyanfeng 展示闰年 C++ 通过 1 MS 260 KB 600 2024-03-01 17:32:27

Tests(1/1):


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


测评信息: