91学习

陪伴你每一天!

判断2020年某一月有几天

#include <stdio.h>


int main(){

int iMonth=0,iDay=0;

printf("enter the month you want to know the days\n");

scanf("%d",&iMonth);

switch(iMonth){

case 1:

case 3:

case 5:

case 7:

case 8:

case 10:

case 12:

iDay=31;

break;

case 4:

case 6:

case 9:

case 11:

iDay=30;

break;

case 2:

iDay=29;

break;

default:

iDay=-1;

break;

}

if(iDay==-1){

printf("there is a error with you enter\n");

}else{

printf("2020.%d has %d days\n",iMonth,iDay);

}

return 0;

}

POSji18790284560.png

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。