闰年展示

题目描述

输入 x,y(1582\le x < y \le 3000)x,y(1582x<y3000) ,输出 [x,y][x,y] 区间中闰年个数,并在下一行输出所有闰年年份数字,使用空格隔开。

输入格式

输出格式

输入输出样例

输入 #1
1989 2001
输出 #1
3
1992 1996 2000
代码:
#include <bits/stdc++.h> using namespace std; int main() { int a,b,s=0; cin>>a>>b; for(register int i=a; i<=b; i++) if(i%400==0||i%4==0&&i%100) s++; cout<<s<<endl; for(register int i=a; i<=b; i++) if(i%400==0||i%4==0&&i%100) cout<<i<<' '; return 0; }
posted @ 2021-05-27 19:19  zhuhaoran0330  阅读(134)  评论(0)    收藏  举报