文章

6

粉丝

0

获赞

33

访问

660

头像
打印日期 题解:新手友好
P1410 华中科技大学机试题
发布于2026年3月12日 17:21
阅读数 111

#include<bits/stdc++.h>
using namespace std;
int f[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int main(){
	int year,days;
	while(scanf("%d%d",&year,&days)!=EOF){
		f[2]=28;
		int day = 0; 
		if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) f[2]=29;
		int cnt=0,w=0;
		while(days>w){
			w+=f[cnt++];
		}
		for(int i=0;i<cnt-1;i++){
			day += f[i];
		}
		day= days-day;
		printf("%04d-%02d-%02d\n",year,cnt-1,day);
	}
	
	return 0;
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发