使用 switch 把小写类型的 char型转为大写。只转换 a, b, c, d, e. 其它的输出

2025-06-28 01:56:18
推荐回答(1个)
回答1:

//假设是字符数组ch[20]
for(int i = 0;i < 20;i++)
{
    switch(ch[i])
    {
        case 'a':
            printf("A\n");
        case 'b':
            printf("B\n");
        case 'c':
            printf("C\n");
        case 'd':
            printf("D\n");
        case 'e':
            printf("E\n");
        default:
            printf("other\n");
    }
}

这样?