Run ID:85855

提交时间:2024-07-20 21:02:23

#include <iostream> using namespace std; bool isLeapYear(int year) { // 如果年份可以被4整除但不能被100整除,或者可以被400整除,则是闰年 return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0); } int main() { int year; cout << "Enter a year between 2000-2500: "; cin >> year; if( (year >= 2000) && (year <= 2500) ) { if (isLeapYear(year)) { cout << "leap year" << endl; } else { cout << "not leap year" << endl; } } return 0; }