文章

15

粉丝

0

获赞

25

访问

1.5k

头像
打印日期 题解:
P1410 华中科技大学机试题
发布于2026年2月10日 11:30
阅读数 87

#include <iostream>
#include <cstdio>
using namespace std;

int month_day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

bool is_leapyear(int x) {
    return (x % 4 == 0 && x % 100 != 0) || (x % 400 == 0);
}

int main() {
    int m, n;
    while(cin >> m >> n) {
        int year = m;
        int month = 1;
        int day = n;
        if(is_leapyear(year)) month_day[1] = 29;
        else month_day[1] = 28;
        while(day > month_day[month-1]) {
            day -= month_day[month-1];
            month++;
        }
        printf("%d-%02d-%02d...

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发