主题:[原创]给出年月日,算出这是一年中的第几天?
#include <stdio.h>
main()
{
int year,m,d,days=0,i;
int month[12]={31,28, 31,30,31,30,31,31,30,31,30,31};
printf("Please enter three number(yy mm dd):");
scanf("%d %d %d",&year,&m,&d);
for(i=0;i<m-1;i++)
days+=month[i];
days+=d;
if(m>2)
if(year%400==0||year%4==0&&year%100!=0)
days++;
printf("%10d\n",days);
}
main()
{
int year,m,d,days=0,i;
int month[12]={31,28, 31,30,31,30,31,31,30,31,30,31};
printf("Please enter three number(yy mm dd):");
scanf("%d %d %d",&year,&m,&d);
for(i=0;i<m-1;i++)
days+=month[i];
days+=d;
if(m>2)
if(year%400==0||year%4==0&&year%100!=0)
days++;
printf("%10d\n",days);
}