返回列表 發帖
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. string s;
  4. char c;
  5. int eval()
  6. {
  7.     cin>>s;
  8.     if(s[0]<'A')
  9.         return stoi(s);
  10.     else
  11.         c=s[0];
  12.     if(c=='h')
  13.     {
  14.         return eval()*3-eval()*2+eval();
  15.     }
  16.     if(c=='g')
  17.     {
  18.         return eval()*2+eval()-7;
  19.     }
  20.     if(c=='f')
  21.     {
  22.         return eval()*2-3;
  23.     }
  24. }
  25. int main()
  26. {
  27.     cout<<eval();
  28.     return 0;
  29. }
複製代碼

TOP

  1. ACCDA
複製代碼

TOP

返回列表