文章

5

粉丝

51

获赞

0

访问

744

头像
打印日期 题解:求大佬解释下为什么只有60%通过率
P1410 华中科技大学机试题
发布于2024年3月19日 14:47
阅读数 170

#include <bits/stdc++.h>
using namespace std; 
int month[]={0,31,28,31,30,31,30,31,31,30,31,30,31}; 
int main() {
    int y,d;
    int m=1;
    while(scanf("%d%d",&y,&d)!=EOF){
        if((y%4==0&&y%100!=0)||(y%400==0)){
            month[2]=29;
        }
        for(int i=1;i<=12;i++){
            if(d>month[i]){
                m=m+1;
                d=d-month[i];
            }
            else{
                printf("%4d-%02d...

登录查看完整内容


登录后发布评论

2 条评论
snake
2024年3月19日 16:20

多组输入的时候,m的初始化应该放在while循环里

另外month[2]需要每次循环初始化为28

赞(1)

泛泛之交 : 回复 snake: 好的多谢大佬

2024年3月28日 21:07