小编Jim*_*ang的帖子

switch语句多字符常量

我正在尝试将其转换为switch语句

if (codeSection == 281)
    cout << "bigamy";
else if (codeSection == 321  ||  codeSection == 322)
    cout << "selling illegal lottery tickets";
else if (codeSection == 383)
    cout << "selling rancid butter";
else if (codeSection == 598)
    cout << "wounding a bird in a public cemetery";
else
    cout << "some other crime";

// Actual switch statement
switch (codeSection)
{
    case '281':
        cout << "bigamy" << endl;
        break;

    case '321':
    case '322':
        cout << "selling illegal lottery tickets" << endl; …
Run Code Online (Sandbox Code Playgroud)

c++ switch-statement

5
推荐指数
1
解决办法
1421
查看次数

标签 统计

c++ ×1

switch-statement ×1