Home > Back-end >  Who can help me to see what was wrong
Who can help me to see what was wrong

Time:12-01

Thank you

CodePudding user response:

What is your expected results?
Purely from the syntax
Case 0 : //is followed by a colon
In addition, each case if you want to do different treatment, should add break at the end of the case statement, that is,
Case 0: break;
Case 1: s +=1; break;//if not break, 1 case execution will continue after the case 2, of course, if your intention is case 1 and case 2 is executed, then another matter
Case 2: s +=2; break;
Case 3: s +=3; break;
Case 4: s +=4; break;

CodePudding user response:

If write case behind the semicolon into the colon, the program can run normally,

CodePudding user response:

No break, then from case 0 is executed to case 4.

CodePudding user response:

refer to the second floor CHXCHXKKK response:
if the case is at the back of the semicolon to write into the colon, the program can run normally,

Thank you, I was too careless

CodePudding user response:

reference 1st floor qybao response:
what is your expected results?
Purely from the syntax
Case 0 : //is followed by a colon
In addition, each case if you want to do different treatment, should add break at the end of the case statement, that is,
Case 0: break;
Case 1: s +=1; break;//if not break, 1 case execution will continue after the case 2, of course, if your intention is case 1 and case 2 is executed, then another matter
Case 2: s +=2; break;
Case 3: s +=3; break;
Case 4: s +=4; break;

Thank you, I was too careless
  • Related