文章
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 m, sum;
Date d;
scanf("%d", &m);
for (int i = 0; i < m; i++)
{
scanf("%d%d%d%d", &d.year, &d.month, &d.day, &sum);
sum += d.day;
d.day = 0;
if ((d.year % 400 == 0) || (d.year % 100 != 0 && d.year % 4 == 0))//计算闰年
{
days[2] = 29;
}
else
{
days[2] = 28;
}
while (sum > days[d.month])//月数累加
{
sum -= days[d.month++];
if (d.month > 12)
{
d.month = 1;
d.year++;
if ((d.year % 400 == 0) || (d.year % 100 != 0 && d.year % 4 == 0))
{
days[2] = 29;
...
登录后发布评论
暂无评论,来抢沙发