7-7 抓老鼠啊~亏了还是赚了? (20 分)
#includeusing namespace std; int main(){ char op; int sad = 0, happy = 0, unhappy = 0, a = 0, b = 0; while(cin >> op) { if(op == '$') break; if(sad && !happy) { cout << "-"; sad--; } else if(unhappy && !happy) { cout << "-"; unhappy--; } else { if(happy) happy--; switch(op) { case 'X': cout << "U"; unhappy = 1; break; case 'T': cout << "D"; sad = 2, a++; break; case 'C': cout << "!"; happy = 2;b++;break; } } } cout << endl; cout << 7*a-3*b << endl; return 0; }