本地对了,但是为毛CE?????????????????????
查看原帖
本地对了,但是为毛CE?????????????????????
532686
Zongmingjun楼主2022/1/15 16:28

哪位大神能帮忙看看~

#include<stdio.h>
#include<string.h>
const int SIZE=10010;
struct Stack{
	int Data[SIZE];
	int top;
	void inits(){
		top=0;
	}
	bool isEmpty(){
		return top==0;
	}
	bool isFull(){
		return top==SIZE-1;
	}
	int size(){
		return top;
	}
	void push(int x){
		Data[++top]=x;
	}
	void pop(){
		top--;
	}
	int getop(){
		return Data[top];
	}
	int getend(){
		return Data[1];
	}
};
int main(){
	char s[1010];
	struct Stack c;
	c.inits();
	scanf("%s",&s);
	for(int i=strlen(s)-1;i>=0;i--) s[i+1]=s[i];
	int num=0;
	for(int i=1;i<=strlen(s);i++) {
		if(s[i]>47&&s[i]<58){
			num=10*num+s[i]-48;
		}
		else if(s[i]=='.'){
			if(s[i-1]>47&&s[i-1]<58) c.push(num);
			num=0;
		}
		else{
			int a,b;
			b=c.Data[c.top];
			c.pop();
			a=c.Data[c.top];
			c.pop();
			switch(s[i]){
				case '+':{
					c.push(a+b);
					break;
				}
				case '-':{
					c.push(a-b);
					break;
				}
				case '*':{
					c.push(a*b);
					break;
				}
				case '/':{
					c.push(a/b);
					break;
				}
			}
		}
	}
	printf("%d\n",c.Data[1]);
	return 0;
}
2022/1/15 16:28
加载中...