IT大道IT大道

首页 >  技术 > 109. 输出月份英文名

109. 输出月份英文名

原文 http://www.cnblogs.com/yongwu/p/6275673.html 2017-01-11 23:34:55 0 评论

输出月份英文名

char *getmonth(int n)
{
    char *month[13] = {"0","January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
    char *pointer;

    switch (n)
    {
        case 1:
            pointer = month[1];
            break;
        case 2:
            pointer = month[2];
            break;
        case 3:
            pointer = month[3];
            break;
        case 4:
            pointer = month[4];
            break;
        case 5:
            pointer = month[5];
            break;
        case 6:
            pointer = month[6];
            break;
        case 7:
            pointer = month[7];
            break;
        case 8:
            pointer = month[8];
            break;
        case 9:
            pointer = month[9];
            break;
        case 10:
            pointer = month[10];
            break;
        case 11:
            pointer = month[11];
            break;
        case 12:
            pointer = month[12];
            break;
        default:
            pointer = NULL;
            break;
    }

    return pointer;
}



猜你喜欢