失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > 平年和闰年c语言程序 C语言平年 平年闰年问题

平年和闰年c语言程序 C语言平年 平年闰年问题

时间:2022-12-25 19:43:59

相关推荐

平年和闰年c语言程序 C语言平年 平年闰年问题

#include

#include

/*:

cmd /k "$(NAME_PART)" & PAUSE & EXIT

mingw32-c++.exe -o $(NAME_PART).exe "$(FULL_CURRENT_PATH)

结构体练习: 定义一个结构体变量(包括年、月、日)。

计算某年某月某日,是本年中的第几天? 注意闰年问题。

普通闰年:能被4整除但不能被100整除的年份为普通闰年。

世纪闰年:能被400整除的为世纪闰年。*/

//8月29,天气晴QST。

struct date {

int year;

int mount;

int day;

}sun;

int date4( int num[])

{

int i;

int temp=0;

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

{

if(sun.year>2)

temp=1;

for(i=0;i

{

temp+=num[i];

}

temp=temp+sun.day;

}

else

{

for(i=0;i

{

temp+=num[i];

}

temp=temp+sun.day;

}

return temp;

}

int main()

{

int n,y,r,temp=0,i,j,k;

int num[13]={31,28,31,30,31,30,31,31,30,31,30,31};

printf("请输入您要查询的年份");

scanf("%d",&sun.year);

printf("请输入您要查询的月份");

scanf("%d",&sun.mount);

printf("请输入您要查询的日");

scanf("%d",&sun.day);

printf("一年的第%d",date4(num));

return 0;

}

如果觉得《平年和闰年c语言程序 C语言平年 平年闰年问题》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。