输入数字对应月份


#include "stdafx.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int main()
{
 int n;
 static char * monthName[] = {"Illegal month","January","February","March","April","May","June"
  "July","August","September","October","November","December"};
 printf_s("input month number:");
 scanf_s("%d",&n,sizeof(n));
 if((n <= 12)&&(n>=1))
  printf_s("month %d is %s \n",n,monthName[n]);
 else
  printf_s("%s\n",monthName[0]);
 system("pause");
 return 0;
}

posted @ 2015-04-13 20:11  码农@163  阅读(338)  评论(0编辑  收藏  举报