解题思路:
注意事项:
参考代码:#include<stdio.h>
int main()
{
int sum,i; //今年的第几天sum
int a[12]={31,29,31,30,31,30,31,31,30,31,30,31}; //对闰年月份赋值
int b[12]={31,28,31,30,31,30,31,31,30,31,30,31}; //对平年月份赋值
struct which //定义结构体
{
int year;
int month;
int day;
}day1; //定义结构体变量day1
scanf("%d%d%d",&day1.year,&day1.month,&day1.day);
sum=day1.day; //令sum等于输入的day
if((day1.year%4==0&&day1.year%100!=0)||day1.year%400==0)
for(i=0;i<day1.month-1;i++)
sum=sum+a[i];
else
for(i=0;i<day1.month-1;i++)
sum=sum+b[i];
printf("%d",sum);
return 0;
}
0.0分
0 人评分