landernal @ 2021-10-15 22:35:46
#include <bits/stdc++.h>
using namespace std;
int top, buttom;
int main(){
//freopen(".in", "r", stdin);
//freopen(".out", "w", stdout);
string a;
cin >> a;
int Stack[10005] = {};
for(int i = 0; i < a.length(); i++) {
if(a[i] >= '0' && a[i] <= '9' && (i == 0 || a[i - 1] == '.')) {
int c = 0, k = i;
while(1) {
if(a[k] == '.') {
break;
}else{
int x = a[k] - '0';
c = c * 10 + x;
k++;
}
}
Stack[top] = c;
top++;
}
if(a[i] < '0' || a[i] > '9') {
char x = a[i];
if(x == '-') {
int w = Stack[top - 2] - Stack[top - 1];
top = top - 2;
Stack[top] = w;
top++;
}
if(x == '+') {
int w = Stack[top - 2] + Stack[top - 1];
top = top - 2;
Stack[top] = w;
top++;
}
if(x == '*') {
int w = Stack[top - 2] * Stack[top - 1];
top = top - 2;
Stack[top] = w;
top++;
}
if(x == '/') {
int w = Stack[top - 2] / Stack[top - 1];
top = top - 2;
Stack[top] = w;
top++;
}
if(x == '@') {
cout << Stack[top - 1];
}
}
}
return 0;
}
by Surge_of_Force @ 2021-10-16 07:29:57
大佬手写栈,OrzOrz