lizihangrq @ 2024-08-11 21:56:53
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<vector>
#include<algorithm>
#include<ctime>
#include<cstdlib>
#include<stack>
using namespace std;
string s;
stack<int>z;
int a[55],n;
int main(){
cin>>s;
int len=s.size();
string ss;
for(int i=0;i<len;i++){
if(a[i]=='@') break;
if(a[i]>='0'&&a[i]<='9'){
n=n*10+a[i]-'0';
}
else if(a[i]=='.'){
z.push(n);
n=0;
}
else{
int x,y,t;
x=z.top();
z.pop();
y=z.top();
z.pop();
if(a[i]=='+') t=x+y;
else if(a[i]=='-') t=y-x;
else if(a[i]=='*') t=x*y;
else if(a[i]=='/') t=y/x;
z.push(t);
}
}
printf("%d",z.top());
return 0;
}
by zhouyuyan__mutao @ 2024-08-16 22:32:11
@lizihangrq 数组开到10001
by chen8866 @ 2024-08-28 22:35:09
头文件可以用 #include<bits/stdc++.h>
by ethan20242024 @ 2024-09-02 21:14:14
你cin的字符串s,却在for循环里用数组a,for循环里改成s[i]。
by sgy_always_ac @ 2024-09-20 16:07:51
注意
int a[55],n;
与
string s;
cin>>s;
而for循环里是a数组
by sgy_always_ac @ 2024-09-20 16:09:21
a数组里没东西你玩啥啊
by sgy_always_ac @ 2024-09-20 16:10:56
z数组里也没东西你玩啥