文章

1

粉丝

27

获赞

0

访问

156

头像
打印日期 题解:
P1410 华中科技大学机试题
发布于2024年3月22日 22:48
阅读数 156

#include<bits/stdc++.h>
using namespace std;

int f[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

bool isLeapYear(int x){
    if(x % 400 == 0 || (x % 4 == 0 && x % 100 != 0)){
        return true;
    }else{
        return false;
    }
}

int main(){
    int y,n;
    while(cin >> y >> n){ //年份y和当年中的第n天 
        if(isLeapYear(y)){
            f[2]=29;
        }else{
            f[2]=28;
        }

        for(int i=1;i<=12;i++){
            if(n > f[i]){
               &nbs...

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发