这个程序怎么来呀?

2025-05-24 01:13:16
推荐回答(3个)
回答1:

帮不成你了,我不会C语言……
只能给你伪代码了 “//”后面是注释

定义整型变量y,m,d,t //ymd年月日,t是结果
定义布尔值r //是否为闰年
读入y,m,d
r=false
if y mod 400=0 then r=true
if y mod 4=0 and y mod 100<>0 then r=true //判断闰年
if m=1 then t=d
if m=2 then t=31+d
if m=3 then t=31+28d
if m=4 then t=31+28+31+d
…………//省略m=5到12,自己写
if m>2 and r=true then t=t+1 //闰年多一天
输出t

C语言大人快来报到!

回答2:

#include
void main(void)
{
int month[13]={0,31,28,31,30,31,30,31,31,30,31,30,31,30};
int monthr[13]={0,31,28,31,30,31,30,31,31,30,31,30,31,30};
int i,j,y,m,d,sum;
printf("Input as year,month,day");
scanf("%d %d %d",&y,&m,&d);
if(y%4==0)
if(y%100==0)
if(y%400==0)
for(i=1;i sum+=monthr[i];
else
for(i=1;i sum+=month[i];
else
for(i=1;i sum+=monthr[i];
else
for(i=1;i sum+=month[i];
printf("there are %d days",sum+d);
}

回答3:

减去当年1月1日再加1不就行了嘛