c语言指针编程题:输入一个月份号,输出该月的英文名。

如题所述

#include "stdio.h"
int main(int argv,char *argc[]){
char m[12][10]={"January","February","March","April","May","June","July",
"August","September","October","November","December"},x;
printf("Enter a month:\nx=");
if(scanf("%d",&x)!=1 || x<1 || x>12){
printf("Input error, exit...\n");
return 0;
}
printf("Your input is %s.\n",m[x-1]); 
return 0;
}

运行样例:

温馨提示:内容为网友见解,仅供参考
第1个回答  2017-11-19
#include
void month(int n)
{
char a[12][10]= {"January","February","March","April","May","June","July","August","September","October","November","December"};
printf("%s\n",a[n-1]);
}
int main()
{
int k;
printf("请输入月份号\n");
scanf("%d",&k);//不要 /n
month(k);
return 0;// 返回值
}

看看我修改后的
相似回答