编一程序,输入月份号,输出该月的英文月名。要求用指针数组处理。

2024年11月30日 01:29
有1个网友回答
网友(1):

建一个字符串数组,数组下标号码 对应月份,里面存该月份 英文词即可。
c 语言程序如下:
#include
int main(){
char *sm[13]={" ","January","February",
"March","April","May","June",
"July","August","September",
"October","November","December"};
int i,m;
printf("input month 1 or 2 or ..or 12\n");
scanf("%d",&m);
printf("It is: %s\n", *(sm+m));
return 0;
}