第三章第三十六题

#include<stdio.h>  
void printdate(int year,int month,int day)  
{  
 int B;  
 if((year%4==0&&year%100!=0)||year%400==0)  
        B=29;  
    else  
        B=28;  
 switch(month)  
 {  
  case 1:if(day<=31)  
      printf("January %d,%d\n",day,year);  
      else  
       printf("错误\n");  
      break;  
  case 2:if(day<=B)  
      printf("February %d,%d\n",day,year);  
      else  
       printf("错误\n");  
      break;  
  case 3:if(day<=31)  
      printf("March %d,%d\n",day,year);  
      else  
       printf("错误\n");  
      break;  
  case 4:if(day<=30)  
      printf("April %d,%d\n",day,year);  
      else  
       printf("错误\n");  
      break;  
  case 5:if(day<=31)  
      printf("May %d,%d\n",day,year);  
      else  
       printf("错误\n");  
      break;  
  case 6:if(day<=30)  
      printf("June %d,%d\n",day,year);  
      else  
       printf("错误\n");  
      break;  
  case 7:if(day<=31)  
      printf("July %d,%d\n",day,year);  
      else  
       printf("错误\n");  
      break;  
  case 8:if(day<=30)  
      printf("August %d,%d\n",day,year);  
      else  
       printf("错误\n");  
      break;  
  case 9:if(day<=31)  
      printf("September %d,%d\n",day,year);  
      else  
       printf("错误\n");  
      break;  
  case 10:if(day<=30)  
      printf("October %d,%d\n",day,year);  
      else  
       printf("错误\n");  
      break;  
  case 11:if(day<=31)  
      printf("Nevember %d,%d\n",day,year);  
      else  
       printf("错误\n");  
      break;  
  case 12:if(day<=30)  
      printf("December %d,%d\n",day,year);  
      else  
       printf("错误\n");  
      break;  
  default:if(day<=31)printf("错误\n");  
 }  
}  
int main()  
{  
 int y,m,d;  
 while(1)  
 {  
  scanf("%d%d%d",&y,&m,&d);  
  printdate(y,m,d);  
 }  
 return 0;  
}  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值