In a switch case statement, it says “duplicate case value” comes up as an error. Anyone know why?

后端 未结 5 766
余生分开走
余生分开走 2021-01-12 12:13

I am working on a rock paper scissors program, but this time the computer chooses rock half the time, scissors a third of the time, and paper only one sixth of the time. The

5条回答
  •  温柔的废话
    2021-01-12 12:50

    I am not sure what you doing, but switch statement should look like this

    switch(computer) 
    {
        case rock1:
        case rock2:
        case rock3:
            c = 1;
            break;
        case scissors1:
        case scissors2:
            c = 3;
            break;
        case paper:
            c = 2;
            break;
    }
    

提交回复
热议问题