文章
33
粉丝
78
获赞
3
访问
18.4k
//通过率60%
#include <stdio.h>
int main() {
int year = 0, month = 0, day = 0;
int n = 0;
int f[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
scanf("%d%d",&year,&n);
if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)
f[2] = 29;
for (int i = 0;i < 12;i++) {
n = n - f[i];
if (n <= f[i + 1]) {
month = i + 1;
day = n;
printf("%4d-%02d-%02d", year, month, day);
return 0;
}
}
}
登录后发布评论
while(scanf("%d%d",&year,&n)!=EOF)
可能有多组测试数据,对于每组数据,
按 yyyy-mm-dd的格式将输入中对应的日期打印出来。