不知道哪里错了,求条
查看原帖
不知道哪里错了,求条
1492053
shuifan楼主2024/10/4 10:42
#include<bits/stdc++.h>
using namespace std;
char a;
int b,c,d;
stack<char> z;
int main(){
	while( a!='@'){
	 while(a!='.'){
			cin>>a;
			if(a=='+' || a=='-' || a=='*' || a=='/'){
				c=z.top()-'0';
				d=z.top()-'0';
				if(a=='+'){
					z.push(c+d);
				}
				if(a=='-'){
					z.push(c-d);
				}
				if(a=='*'){
					z.push(c*d);
				}
				if(a=='/'){
					z.push(c/d);
				}
			}else {
				z.push(a);
			}
		}
	}
	cout<<z.top();
	return 0;
}
2024/10/4 10:42
加载中...