全T求调
查看原帖
全T求调
1143775
__yiLIUyi__楼主2024/7/25 14:50
#include<bits/stdc++.h>
using namespace std;
stack<int>n;
char c;
string str;
int num,i,top,k;
int main(){
	cin>>str;
	for(c=str[k];c!='@';k++){
		if('9'>=c&&c>='0'){
			int a=c-'0';
			num=num*10+a;
			i=1;
		}
		else if(c=='.'){
			n.push(num);
			num=i=0;
			top++;
		}
		else{
			int a=n.top();
			n.pop();
			int b=n.top();
			n.pop();
			if(c=='+')n.push(b+a);
			if(c=='-')n.push(b-a);
			if(c=='*')n.push(b*a);
			if(c=='/')n.push(b/a);
		}
	}cout<<n.top();
}
2024/7/25 14:50
加载中...