Run ID:111458
提交时间:2025-03-02 11:24:21
#include <iostream> using namespace std; // 判断年份是否为闰年 bool isLeapYear(int year) { if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) { return true; } return false; } int main() { int x, y; cin >> x >> y; // 读取两个年份 int leapYearCount = 0; // 闰年计数 for (int year = x; year <= y; ++year) { if (isLeapYear(year)) { leapYearCount++; } } // 输出闰年数 cout << leapYearCount << endl; return 0; }