忘调了
```cpp
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cmath>
#include<cstring>
#include<string>
#include<vector>
using namespace std;
const int N=30022;
int tot,tot1,up[N],down[N],s2[N];
char c,s[N],s1[N],val[N];
int tot2,p,p1=0;
int main()
{
int i,j,k;
while(cin>>c)
{
if(c=='$') break;
if(c=='>'||c=='<'||c=='.'||c==','||c=='+'||c=='-'||c=='['||c==']')
s[++tot]=c;
}
// for(i=1;i<=tot;++i) printf("%c",s[i]);
//cout<<endl;
while(cin>>c)
{
if(c=='$') break;
s1[++tot1]=c;
}
for(i=1;i<=tot;++i)
if(s[i]=='[')
s2[++tot2]=i;
else if(s[i]==']')
{
up[s2[tot2]]=i;
down[i]=s2[tot2];
--tot2;
}
i=1;p=1;
while(i<=tot)
{
if(s[i]=='<')
--p;
if(s[i]=='>')
++p;
if(s[i]=='+')
val[p]++;
if(s[i]=='-')
val[p]--;
if(s[i]=='.')
printf("%c",val[p]);
if(s[i]==',')
{
if((p1+1)<=tot1)
{
++p1;
val[p]=s1[p1];
}
else val[p]=-1;
}
if(s[i]=='[')
{
if(val[p]==0) i=up[i];
}
else if(s[i]==']')
{
if(val[p]) i=down[i];
}
++i;
}
return 0;
}
```
by luyanting @ 2018-03-13 01:03:33
提示:用getchar读入数据
by qq1010903229 @ 2018-05-09 20:49:29
@[luyanting](/space/show?uid=36571)
by qq1010903229 @ 2018-05-09 20:49:44
谢谢我懂了
by luyanting @ 2018-07-18 10:23:56