用的是题解的%c判断字符的方法,但是做了几个小时都过不去,请教一下各位。

P1981 [NOIP2013 普及组] 表达式求值

``` #include<bits/stdc++.h> #define ll long long using namespace std; stack<ll>a; char cc,c; ll shu(){ ll temp=0; c=getchar(); while(c>='0' && c<='9'){ temp=temp*10+c-'0'; c=getchar(); } temp%=10000; cc=c; return temp; } int main(){ a.push(shu()); while(cc!='\n'){ if(cc=='*'){ int x=shu()*a.top()%10000; a.pop(); a.push(x); } else a.push(shu()); } ll sum=0; while(!a.empty()){ sum=(sum+a.top())%10000; a.pop(); } cout<<sum; return 0; } ```
by SHUYONGRUI @ 2024-02-04 10:14:02


|