习题11-1 输出月份英文名 (15 分)

#include <stdio.h>

char *getmonth(int n);

int main()
{
    int n;
    char *s;

    scanf("%d", &n);
    s = getmonth(n);
    if (s == NULL) printf("wrong input!\n");
    else printf("%s\n", s);

    system("pause");
    return 0;
}

/* 你的代码将被嵌在这里 */
char *getmonth(int n) {
    char *month[13] = { "0", "January", "February", "March", "June", "July", "August", "September", "October", "November", "December" };
    if (n < 1 || n > 12)
        return NULL;
    else
        return month[n];
}

 

posted @ 2022-02-27 20:59  JamesGordan  阅读(42)  评论(0)    收藏  举报