为啥报错??求助
查看原帖
为啥报错??求助
726770
lisiyuan19楼主2022/7/17 10:30
#include<stdlib.h>
#include<cstdio>
#include<cmath>
#include<stack>
using  namespace std;
stack <int> s;int x,y;char a;
int main(){
	
	while(a!='@'){
		while(scanf("%c",&a)!='.'){
			if(a>='0'&&a<='9'){
				int a1=atoi(a);
				s.push(a1);
			}
			if(a=='+') x=s.top();s.pop();y=s.top();s.pop();s.push(y+x);
			if(a=='-') x=s.top();s.pop();y=s.top();s.pop();s.push(y-x);
			if(a=='*') x=s.top();s.pop();y=s.top();s.pop();s.push(y*x);
			if(a=='/') x=s.top();s.pop();y=s.top();s.pop();s.push(y/x);
		}
	}
	printf("%d",s.top());
	return 0;
}
 
2022/7/17 10:30
加载中...