39.第几天——C语言初学者百题大战之十八

原文链接: http://www.cnblogs.com/Estwind/p/9784751.html
#include
int main()
{
int i,j,year,month,day,MONTH[12]={31,28,31,30,31,30,31,31,30,31,30,31},D;
while(scanf("%d-%d-%d",&year,&month,&day)!=EOF)
{
if((year%4==0&&year%100!=0)||year%400==0)
{
MONTH[1]=29;
}
D=0;
for(i=0;i1;i++)
{
D+=MONTH[i];
}
if(day<=MONTH[i])
{
D=D+day;
printf("%d\n",D);
}
else
printf("No\n");
}
} 

 

 

 

#include
int main()
{
    int a,b,c,x;
    scanf("%d-%d-%d",&a,&b,&c);
    if((a%4==0&&a%100!=0)||(a%400==0))
{
    if(b==1){
    x=c;
    printf("%d\n",x);
    }
    if(b==2){
    x=c+31;
    printf("%d\n",x);
    }
     if(b==3){
    x=c+31+29;
    printf("%d\n",x);
    }
     if(b==4){
    x=c+31+29+31;
    printf("%d\n",x);
    }
     if(b==5){
    x=c+31+29+31+30;
    printf("%d\n",x);
    }
     if(b==6){
    x=c+31+29+31+30+31;
    printf("%d\n",x);
    }
     if(b==7){
    x=c+31+29+31+30+31+30;
    printf("%d\n",x);
    }
     if(b==8){
    x=c+31+29+31+30+31+30+31;
    printf("%d\n",x);
    }
     if(b==9){
    x=c+31+29+31+30+31+30+31+31;
    printf("%d\n",x);
    }
     if(b==10){
    x=c+31+29+31+30+31+30+31+31+30;
    printf("%d\n",x);
    }
     if(b==11){
    x=c+31+29+31+30+31+30+31+31+30+31;
    printf("%d\n",x);
    }
     if(b==12){
    x=c+31+29+31+30+31+30+31+31+30+31+30;
    printf("%d\n",x);
    }
}
else
{
    if(b==1){
    x=c;
    printf("%d\n",x);
    }
    if(b==2){
    x=c+31;
    printf("%d\n",x);
    }
     if(b==3){
    x=c+31+28;
    printf("%d\n",x);
    }
     if(b==4){
    x=c+31+28+31;
    printf("%d\n",x);
    }
     if(b==5){
    x=c+31+28+31+30;
    printf("%d\n",x);
    }
     if(b==6){
    x=c+31+28+31+30+31;
    printf("%d\n",x);
    }
     if(b==7){
    x=c+31+28+31+30+31+30;
    printf("%d\n",x);
    }
     if(b==8){
    x=c+31+28+31+30+31+30+31;
    printf("%d\n",x);
    }
     if(b==9){
    x=c+31+28+31+30+31+30+31+31;
    printf("%d\n",x);
    }
     if(b==10){
    x=c+31+28+31+30+31+30+31+31+30;
    printf("%d\n",x);
    }
     if(b==11){
    x=c+31+28+31+30+31+30+31+31+30+31;
    printf("%d\n",x);
    }
     if(b==12){
    x=c+31+28+31+30+31+30+31+31+30+31+30;
    printf("%d\n",x);
}
    return 0;
}
}

 

转载于:https://www.cnblogs.com/Estwind/p/9784751.html

你可能感兴趣的:(39.第几天——C语言初学者百题大战之十八)