您的位置:首页 > 其它

判断闰年

2015-09-16 20:42 316 查看
如果一年能被4整除且不能被100整除,或者改年能被400整除,则是闰年:

<span style="font-size:18px;">#include<iostream>
#include<stdio.h>
#include<string>

using namespace std;
int main()
{
	int year;
	cout << "输入年份" << endl;
	cin >> year;
	cout << "------------------" << endl;
	cout << "|                 |" << endl;
	if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
		cout << "闰年" << year << endl;
	else
		cout << "不是闰年" << endl;

    system("pause");
	return 0;
}</span>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: