请教switch里面的为什么第一个case 0要用break,而第二个case不用break?
#include <iostream>#include <stdlib.h>#include <time.h>using namespace std;int main(){ int a,b,numOfQues=0,numOfRight=0; char inchar; srand((unsigned int)time(NULL)); cout<<"……欢迎来做两位数的加减法……"<<endl; do { int temp=rand()%2; a=rand()%100; b=rand()%100; switch(temp) { case 0: { int ans; cout<<a<<'+'<<b<<'='; cin>>ans; if(a+b==ans){ numOfRight++; cout<<"恭喜您!答对了!"<<endl; }else cout<<"答错了,再接再厉!"<<endl; break; } case 1: { int ans; cout<<a<<"-"<<b<<"="; cin>>ans; if(a-b==ans) { numOfRight++; cout<<"恭喜您!回答正确!"<<endl; }else cout<<"不好意思,回答错误!"<<endl; } } numOfQues++; cout<<"您还要再做一题吗?(键入N退出)"<<endl; cin>>inchar; }while(inchar!='n'&&inchar!='N'); cout<<"您的答案正确率为:"<<numOfRight/numOfQues*100/100<<"%.再见!"<<endl; return 0;}