2个回答
展开全部
#include<stdio.h>
struct
{int year;
int month;
int day;
}tian;
void main()
{int days(int year,int month,int day);
int s;
printf("input the date:");
scanf("%d %d %d",&tian.year,&tian.month,&tian.day);
s=days(tian.year,tian.month,tian.day);
printf("this are %d days.",s);
}
int days(int year,int month,int day)
{int i=month,s,a[13]={0,31,28,31,30,31,30,31,31,30,31,30,31},sum=0,leap,j;
if(year%4==0)
{
if(year%100==0)
{
if(year%400==0)
leap=1;
else
leap=0;}
else
leap=1;}
else
leap=0;
if(leap&&i>2)
{for(j=1;j<i;j++)
sum=sum+a[j];
s=sum+day+1;}
else
{for(j=1;j<i;j++)
sum=sum+a[j];
s=sum+day;}
return(s);
}
struct
{int year;
int month;
int day;
}tian;
void main()
{int days(int year,int month,int day);
int s;
printf("input the date:");
scanf("%d %d %d",&tian.year,&tian.month,&tian.day);
s=days(tian.year,tian.month,tian.day);
printf("this are %d days.",s);
}
int days(int year,int month,int day)
{int i=month,s,a[13]={0,31,28,31,30,31,30,31,31,30,31,30,31},sum=0,leap,j;
if(year%4==0)
{
if(year%100==0)
{
if(year%400==0)
leap=1;
else
leap=0;}
else
leap=1;}
else
leap=0;
if(leap&&i>2)
{for(j=1;j<i;j++)
sum=sum+a[j];
s=sum+day+1;}
else
{for(j=1;j<i;j++)
sum=sum+a[j];
s=sum+day;}
return(s);
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你不早说,我早就编好了,706所最后一道大题就是这个……呵呵,今天或者明天我再上传给你,可能我没空
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询