C语言,求大佬

P1449 后缀表达式

你要不把两个测试用的printf(满了和空的)删了试试
by Wanxue @ 2023-07-29 14:59:20


``` #include<bits/stdc++.h> using namespace std; string s; long long a[505], top = -1,res; void calc(char op) { long long x = a[top --]; long long y = a[top --]; if(op == '+'){ a[++ top] = y + x;return; }else if(op == '-'){ a[++ top] = y - x;return; }else if(op == '*'){ a[++ top] = y * x;return; }else if(op == '/'){ a[++ top] = y / x;return; } } int main() { getline(cin, s); for(int i = 0; s[i] != '@'; i ++) { long long x = 0; while(s[i] >= '0' && s[i] <= '9') x = x * 10 + s[i ++] - '0'; if(x) a[++ top] = x; else if(s[i] != ' ') calc(s[i]); } cout << a[top]; return 0; } ``` 或吧满了,空的删了逝逝
by winner_0207 @ 2023-07-29 15:21:16


@[Wanxue](/user/608112) 把测试用的删了也还是一样的错误
by wanan2203ouchengli @ 2023-07-29 15:42:46


@[NBxzz2012](/user/781714) 感谢分享 不过我还是想练习顺序表,我这错误原因似乎是我的语法问题
by wanan2203ouchengli @ 2023-07-29 15:45:20


|