P5737 【深基7.例3】闰年展示

题目传送门

#include <bits/stdc++.h>

using namespace std;

//是不是闰年
bool isRunYear(int y) {
    if ((y % 4 == 0 && y % 100 != 0) || y % 400 == 0) return true;
    return false;
}

const int N = 2010;
int a[N];
int idx;

int main() {
    int x, y;
    cin >> x >> y;
    for (int i = x; i <= y; i++)if (isRunYear(i)) a[idx++] = i;
    cout << idx << endl;
    for (int i = 0; i < idx; i++) cout << a[i] << " ";
    return 0;
}
原文地址:https://www.cnblogs.com/littlehb/p/15575540.html