卡扎菲最后死亡视频:这个程序怎么来呀?

来源:百度文库 编辑:中科新闻网 时间:2024/05/11 14:50:33
现在需要帮我编个程序,是这样的
编个程序,输入年月日,就可以知道这天是该年的第几天
用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 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语言大人快来报到!

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