#include<bits/stdc++.h>
using namespace std;
string s;
int t,f;
vector<string>ans;
int main()
{
int n;
scanf("%d\n",&n);
while(n--)
{
getline(cin,s);
t=1,f=0;
s += " end";
string x;
stringstream ss(s);
int id=100;
while(ss>>x)
{
if(x == "or")
{
printf("%d(j%s,%s,%s,%d)\n",id,ans[1].c_str(),ans[0].c_str(),ans[2].c_str(),t);
t=id++;
printf("%d(j,_,_,%d)\n",id,id+1);
id++;
ans.clear();
}
else if(x == "end")
{
printf("%d(j%s,%s,%s,%d)\n",id++,ans[1].c_str(),ans[0].c_str(),ans[2].c_str(),t);
/* t=id++*/;
printf("%d(j,_,_,%d)\n",id++,f);
/* id++;*/
ans.clear();
}
else if(x == "and")
{
printf("%d(j%s,%s,%s,%d)\n",id,ans[1].c_str(),ans[0].c_str(),ans[2].c_str(),id+2);
id++;
printf("%d(j,_,_,%d)\n",id,f);
f=id++;
ans.clear();
}
else ans.push_back(x);
}
}
return 0;
}
3515 翻译布尔表达式
最新推荐文章于 2020-11-13 11:12:34 发布