求助模拟栈

P1449 后缀表达式

朕在世界之巅 @ 2020-07-12 17:12:06

RT, 3蛙3重可还行,失败记录

```cpp #include <bits/stdc++.h> using namespace std; long simstk[1024]; int main(void) { int i=0,num=0,ch; while((ch = getchar())!=64) { if(ch >= 48 && ch <= 57) num*=10,num+=ch^48; else if(ch == 49) simstk[++i]=num,num=0; else { if(ch == 43) simstk[i-1]+=simstk[i]; else if(ch == 45) simstk[i-1]-=simstk[i]; else if(ch == 42) simstk[i-1]*=simstk[i]; else if(ch == 47) simstk[i-1]/=simstk[i]; simstk[i]=0,i--; } } printf("%ld",simstk[1]); return 0; } ```

by 朕在世界之巅 @ 2020-07-12 17:16:43

没有人救我嘛555


by 朕在世界之巅 @ 2020-07-12 17:16:59

忽略名字


by Dimly_dust @ 2020-07-12 17:21:17

挺有规律


by 朕在世界之巅 @ 2020-07-12 17:21:33

@Dimly_dust ?


by 朕在世界之巅 @ 2020-07-12 17:22:00

@朕在世界之巅 蛙重蛙重蛙重 我还QwQwQw呢


by Dimly_dust @ 2020-07-12 17:22:48

哈,帮你看下吧


by 朕在世界之巅 @ 2020-07-12 17:27:43

@Dimly_dust 谢


by Dimly_dust @ 2020-07-12 17:32:40

@朕在世界之巅 ch是char,不是int


by 朕在世界之巅 @ 2020-07-12 17:34:55

@Dimly_dust 可是char本身就是8位unsigned int


by 朕在世界之巅 @ 2020-07-12 17:37:10

改成char没有变化

Record


| 下一页