#include
#include
void main()
{int calculatedDays(int year,int month,int day);
int year,month,day;
scanf("%4d,%4d,%4d\n",&year,&month,&day);
calculatedDays(year,month,day);
system("pause");
}
int calculatedDays(int year,int month,int day)
{int leap,totaldays;
if((year%4==0&&year%100!=0)||(year%400==0))
leap=1;
else
leap=0;
while(leap==1)
{if(month==1)
totaldays=day;
else if(month==2)
totaldays=31+day;
else if(month==3)
totaldays=31+29+day;
else if(month==4)
totaldays=31+29+31+day;
else if(month==5)
totaldays=31+29+31+30+day;
else if(month==6)
totaldays=31+29+31+30+31+day;
else if(month==7)
totaldays=31+29+31+30+31+30+day;
else if(month==8)
totaldays=31+29+31+30+31+30+31+day;
else if(month==9)
totaldays=31+29+31+30+31+30+31+31+day;
else if(month==10)
totaldays=31+29+31+30+31+30+31+31+30+day;
else if(month==11)
totaldays=31+29+31+30+31+30+31+31+30+31+day;
else
totaldays=31+29+31+30+31+30+31+31+30+31+30+day;
break;
}
while(leap==0)
{if(month==1)
totaldays=day;
else if(month==2)
totaldays=31+day;
else if(month==3)
totaldays=31+28+day;
else if(month==4)
totaldays=31+28+31+day;
else if(month==5)
totaldays=31+28+31+30+day;
else if(month==6)
totaldays=31+28+31+30+31+day;
else if(month==7)
totaldays=31+28+31+30+31+30+day;
else if(month==8)
totaldays=31+28+31+30+31+30+31+day;
else if(month==9)
totaldays=31+28+31+30+31+30+31+31+day;
else if(month==10)
totaldays=31+28+31+30+31+30+31+31+30+day;
else if(month==11)
totaldays=31+28+31+30+31+30+31+31+30+31+day;
else
totaldays=31+28+31+30+31+30+31+31+30+31+30+day;
break;
}
return(printf("該日是該年的第:%4d天\n",totaldays));
}
#include <stdio.h>
#include <stdlib.h>
int calculatedDays(int year,int month,int day);
void main()
{
int year,month,day;
scanf("%d %d %d",&year,&month,&day);
calculatedDays(year,month,day);
system("pause");
}
int calculatedDays(int year,int month,int day)
{
int leap,totaldays;
if((year%4==0&&year%100!=0)||(year%400==0))
leap=1;
else
leap=0;
if(leap==1)
{
if(month==1)
totaldays=day;
else if(month==2)
totaldays=31+day;
else if(month==3)
totaldays=31+29+day;
else if(month==4)
totaldays=31+29+31+day;
else if(month==5)
totaldays=31+29+31+30+day;
else if(month==6)
totaldays=31+29+31+30+31+day;
else if(month==7)
totaldays=31+29+31+30+31+30+day;
else if(month==8)
totaldays=31+29+31+30+31+30+31+day;
else if(month==9)
totaldays=31+29+31+30+31+30+31+31+day;
else if(month==10)
totaldays=31+29+31+30+31+30+31+31+30+day;
else if(month==11)
totaldays=31+29+31+30+31+30+31+31+30+31+day;
else
totaldays=31+29+31+30+31+30+31+31+30+31+30+day;
}
else
{
if(month==1)
totaldays=day;
else if(month==2)
totaldays=31+day;
else if(month==3)
totaldays=31+28+day;
else if(month==4)
totaldays=31+28+31+day;
else if(month==5)
totaldays=31+28+31+30+day;
else if(month==6)
totaldays=31+28+31+30+31+day;
else if(month==7)
totaldays=31+28+31+30+31+30+day;
else if(month==8)
totaldays=31+28+31+30+31+30+31+day;
else if(month==9)
totaldays=31+28+31+30+31+30+31+31+day;
else if(month==10)
totaldays=31+28+31+30+31+30+31+31+30+day;
else if(month==11)
totaldays=31+28+31+30+31+30+31+31+30+31+day;
else
totaldays=31+28+31+30+31+30+31+31+30+31+30+day;
}
return(printf("該日是該年的第:%4d天\n",totaldays));
}