C语言 编写程序,当输入数月份时,显示相应英文月份名称。

C语言 编写程序,当输入数月份时,显示相应英文月份名称。例如,输入1时,输出January.

#include<stdio.h>

int main(void){

    char *month[]={"January","February","March","April","May","June","July","August","September","October","November","December"};

    int i;

    printf("**************输入0结束循环************\n");

    while(1){

        printf("请输入月份号:");

        scanf("%d",&i);

        if(i==0){

        return 0;                                                           

        }   

        printf("该月的英文名为:%s\n",month[i-1]);

    }   

}

温馨提示:内容为网友见解,仅供参考
第1个回答  推荐于2018-02-23
#include<stdio.h>
void main()
{
int n;
printf("请输入数字:");
scanf("%d",&n);
switch(n)
{
case 1:printf("Jan \n");break;
case 2:printf("Feb \n");break;
case 3:printf("Mar \n");break;
case 4:printf("Apr \n");break;
case 5:printf("May \n");break;
case 6:printf("Jun \n");break;
case 7:printf("Jul \n");break;
case 8:printf("Agu \n");break;
case 9:printf("Sep \n");break;
case 10:printf("Oct \n");break;
case 11:printf("Nov \n");break;
case 12:printf("Dec \n");break;
}
}本回答被提问者和网友采纳
相似回答