逆天而行


私信TA

用户名:044553

访问量:282

签 名:

等  级
排  名 3428
经  验 1862
参赛次数 0
文章发表 1
年  龄 0
在职情况 学生
学  校 九江学院
专  业

  自我简介:

解题思路:

注意事项:

参考代码:

#include<stdio.h>

struct Date

{

int year;

int month;

int day;

}time;//设置一个结构体

int main()

{

int i;

while (scanf("%d%d%d", &time.year, &time.month, &time.day) != EOF)

{

int n = 0, arr[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };//将每个月的天数存入数组

if ((time.year % 4 == 0 && time.year % 100 != 0) || (time.year % 400 == 0))

arr[1] = 29;            //注意闰年问题

for (i = 0; i < time.month-1;i++)

n += arr[i];            //将之前每个月天数加起来,求和

printf("%d\n", n + time.day);

}

return 0;

}


 

0.0分

2 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区