java与c++中的分支语句switch的不同

java中的switch后可用字符串,而C++只能用字符和数字

                        switch(suffix)
                        {
                            case "js":
                                contentType="text/javascript";
                                break;
                            case "css":
                                contentType="text/css";
                                break;
                        }

c++

    switch (x)
    {
    case 0:
    case 1:
    case 2:
        rth = 3;
        break;
    case 3:
    case 4:
    case 5:
        rth = 6;
        break;
    default:
        rth = 9;
        break;
    }
    switch (y)
    {
    case 0:
    case 1:
    case 2:
        colth = 3;
        break;
    case 3:
    case 4:
    case 5:
        colth = 6;
        break;
    default:
        colth = 9;
        break;
    }

你可能感兴趣的:(java,c++,python)