第18课 闰年与平年 《小学生C++趣味编程》

#include<iostream>
using namespace std;
int main()
{
	bool flag;
	int year;
	
	cout<<"请输入一个年份:";
	cin>>year;
	
	if((year%4==0&&year%100!=0)||year%400==0)
		flag=true;
	else
		flag=false;
	
	if(flag)	          
		cout<<year<<"是闰年"<<endl;
	else
		cout<<year<<"是平年"<<endl;
	
	return 0;
} 
/*
试编一个程序,输入一年份判断是闰年还是平年。
http://noi.openjudge.cn/ch0104/17/
*/

 


 

 

猜你喜欢

转载自blog.csdn.net/dllglvzhenfeng/article/details/121885809
今日推荐