- /*
- 需求:实现判断输入年份是否是闰年,并能不断地判断,当输入1就能关闭程序。
- */
- #include<iostream>
- using namespace std;
- int main()
- {
- int y;
- cin>>y;
- while(y!=1)//控制程序的开关
- {
- //判断算法
- if(y%4==0&&y%100!=0)
- cout<<y<<"是闰年"<<endl;
- else if(y%400==0)
- cout<<y<<"是闰年"<<endl;
- else
- cout<<y<<"不是闰年"<<endl;
- cin>>y;
- }
- return 1;
- }
- //该片段来自于http://www.codesnippet.cn/detail/2101201511588.html
来源: http://www.codesnippet.cn/detail/2101201511588.html