#include<iostream>
using namespace std;
struct number
{
long long n;
char c='e';
} a[100005];
int top;
number want()
{
number tmp;
scanf("%lld%c",&tmp.n,&tmp.c);
tmp.n%=10000;
if(tmp.c>='0'&&tmp.c<='9')
throw 1;
else if(tmp.c!='+'&&tmp.c!='*')
tmp.c='e';
return tmp;
}
int main()
{
top=0;
a[++top]=want();
while(a[1].c!='e'/*end*/)
{
if(a[top].c=='+')
{
a[++top]=want();
continue;
}
if(a[top].c=='*')
{
number tmp=want();
a[top].n*=tmp.n;
a[top].n%=10000;
a[top].c=tmp.c;
continue;
}
if(a[top].c=='e')
{
top--;
a[top].n+=a[top+1].n;
a[top].n%=10000;
a[top].c='e';
continue;
}
cout<<'A';
return 0;
}
cout<<a[1].n;
return 0;
}
一开始我want写的是
if(tmp.c==EOF)
tmp.c='e';
难道输入的末尾不是EOF吗?