#include <iostream>
using namespace std;
int main()
{
int year;
cout << "please enter year" << endl;
while (cin >> year)
{
if (year > 0)
break;
else
{
cout << "error" << endl;
continue;
}
}
{
if( (year % 4 == 0 && year % 100 != 0)||(year%400==0))
cout << "a leap year" << endl;
else
cout << "not leap year" << endl;
}
return 0;
}
闰年判定:能被400整除。或者能被4整除但不能被100整除。其余的年份都为平年。
c++闰年平年的判断
最新推荐文章于 2024-07-17 11:02:59 发布