文章
25
粉丝
364
获赞
58
访问
226.7k
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
typedef struct
{
int year, month, day;
} Date;
int days[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int main()
{
int y,n;
Date d;
while (scanf("%d%d", &y, &n) != EOF)
{
d.year=y;
if ((d.year%400==0)||(d.year%100!=0&&d.year%4==0))//判断闰年
{
days[2]=29;
}
else
{
days[2]=28;
}
int i;
for (i = 1; n > days[i]; i++)//计算月份和日
{
n-=days[i];
}
d.month=i;
d.day=n;
printf("%d-%02d-%02d\n",d.year,d.month,d.day);
}
//system("pause");
return 0;
}
登录后发布评论
暂无评论,来抢沙发