这个程序怎么来呀?

来源:百度知道 编辑:UC知道 时间:2024/05/21 15:10:23
现在需要帮我编个程序,是这样的
编个程序,输入年月日,就可以知道这天是该年的第几天
用C语言来编的呀,具体的程序,具体 一点呀

#include <stdio.h>
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<m;i++)
sum+=monthr[i];
else
for(i=1;i<m;i++)
sum+=month[i];
else
for(i=1;i<m;i++)
sum+=monthr[i];
else
for(i=1;i<m;i++)
sum+=month[i];
printf("there are %d days",sum+d);
}

帮不成你了,我不会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