#include <iostream>
using namespace std;
int main()
{
int year;
bool isLeapYear;
cout << "请输入年份:";
cin >> year;
isLeapYear = ((year % 4 ==0 && year % 100 != 0) || (year % 400 == 0));
if(isLeapYear)
cout << year << "是闰年";
else
cout << year << "是平年";
}
C++ 判断年份是否为闰年
最新推荐文章于 2026-03-25 10:21:36 发布
这篇文章展示了如何使用C++编写一个简单的程序,通过用户输入的年份,判断是否为闰年,输出相应的结果。
1413

被折叠的 条评论
为什么被折叠?



