主要就是分支的考察吧
#include <iostream>
using namespace std;
int main(){
int k;
int a, b;
while (scanf("%d", &k) && k != 7){
if (k == 1){
char op; int v;
cin >> op >> v;
if (op == 'A') a = v;
else b = v;
}else if (k == 2){
char op;
cin >> op;
if (op == 'A') cout << a << endl;
else cout << b << endl;
}else if (k == 3){
char op1, op2;
cin >> op1 >> op2;
if (op1 == op2){
if (op1 == 'A') a *= 2;
else b *= 2;
}else {
if (op1 == 'A') a = a + b;
else b = b + a;
}
}else if (k == 4){
char op1, op2;
cin >> op1 >> op2;
if (op1 == op2){
if (op1 == 'A') a = a * a;
else b = b * b;
}else {
if (op1 == 'A') a = a * b;
else b = b * a;
}
}else if (k == 5){
char op1, op2;
cin >> op1 >> op2;
if (op1 == op2){
if (op1 == 'A') a = 0;
else b = 0;
}else {
if (op1 == 'A') a = a - b;
else b = b - a;
}
}else if (k == 6){
char op1, op2;
cin >> op1 >> op2;
if (op1 == op2){
if (op1 == 'A') a = 1;
else b = 1;
}else {
if (op1 == 'A') a = a / b;
else b = b / a;
}
}
}
return 0;
}