编一程序,输入月份号,输出该月的英文月名。例如,输入“3”,则输出“March”,要求用指针数组处理。
#include<stdio.h>
void fun(int *a){
switch(*a)
{
case 1:printf("January 1月\n");break;
case 2:printf("February 2月\n");break;
case 3:printf("March 3月\n ");break;
case 4:printf("April 4月\n");break;
case 5:printf("May 5月\n");break;
case 6:printf("June 6月\n ");break;
case 7:printf("July 7月\n");break;
case 8:printf("August 8月\n");break;
case 9:printf("September 9月\n");break;
case 10:printf("October 10月\n ");break;
case 11:printf("November11月\n");break;
case 12:printf("December 12月\n");break;
}}
void main(){
int data;
scanf("%d",&data);
if(data>=1 && data<=12){fun(&data);}
else{printf("error!\n");}
}