程序设计:输入某年某月某日判断这天是这一年的第多少天的流程图,以及报告表

2025-02-26 07:08:12
推荐回答(3个)
回答1:

matlab语言的程序可以不?
year=input('please input the value of year:');
month=input('please input the value of month:');
day=input('please input the value of day:');
days=day;
if (mod(year,100)==0&&mod(year,400)~=0)||mod(year,4)~=0
disp('这一年不是闰年!');
jj=0;
elseif (mod(year,4)==0&&mod(x,100)~=0)||(mod(year,400)==0)
disp('这一年为闰年!');
jj=1;
end
for i=1:month-1
switch(i)
case {1,3,5,7,8,10,12},
days=days+31;
case {4,6,9,11},
days=days+30;
case 2,
days=days+28+jj;
end
end
fprintf('the day of year:%d.%d.%d is %d\n',year,month,day,days);

回答2:

include "stdio.h"
int sun_day(int,int);
int leap(int year);
main()
{
int year,month,day,days;
printf("Input date(year,month,day):");
scanf("%d,%d,%d",&year,&month,&day);
printf("%d%d%d",year,month,day);
days=sum_day(month,day);
if(leap(year)&&month>=3)
days=days+1;
printf("is the %dth day in this year.\n",days);
}
int sum_day(int month,int day)
{
int day_tab[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int i;
for(i=1;i day+=day_tab[i];
return day;
}
int leap(int year)
{
int leap;
leap=year%4==0&&year%100!=0||year%400==0;
return leap;
}

回答3:

不错!!

但是在能不能不简单一点!我不太懂matlab语言的程序!!
比如说用for循环等.......