tip:switch:case{} 中需要加break;
#include <iostream>
using namespace std;
int main()
{
int r, y, g;//r表示红色,y表示黄色,g表示绿色
int n;
int alltime=0;
cin >> r >> y >> g;
cin >> n;
for(int i=0; i<n; i++){
int k, t;
cin >> k >> t;
switch (k) {
case 0:
alltime+=t;
break;
case 1:
alltime+=t;
break;
case 2:
alltime=alltime+t+r;
break;
}
}
cout << alltime;
return 0;
}
来源:CSDN
作者:我一直在矛盾
链接:https://blog.csdn.net/weixin_42546737/article/details/104108534