出道题 大家来做做..
编一个程序,输入月份号,输出该月的英文月名。例如:输入“3”,则输出“March”,要求用指针数组处理
#include "stdio.h"
void main(){ int month=1; static char *English[12]={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"}; while (month!=0) { printf("please input the month(1~12,0 to quit):"); scanf("%d",&month); if(month>0&&month<=12) printf("%s\n",English[month-1]); else if(month!=0) printf("the month is out of range\n"); } }
该程序可以重复输入,直到输入的月份为0时结束程序.