#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;
}