CE,求调,教会必关!!!
查看原帖
CE,求调,教会必关!!!
1716453
LinJiawei1210楼主2025/8/4 14:07
#include<bits/stdc++.h>
using namespace std;
int st[101];
char s[256];
int comp(char s[256]) {
    int i=0,top=0,x,y;
    while(i<=strlen(s)-2) {
        switch(s[i]) {
            case '+':st[--top]+=st[top+1];break;
            case '-':st[--top]-=st[top+1];break;
            case '*':st[--top]*=st[top+1];break;
            case '/':st[--top]/=st[top+1];break;
            default:x=0;while(s[i]!=' ') x=x*10+s[i++]-'0';st[++top]=x;break;
        }
        i++;
    }
    return st[top];
}
int main() {
    gets(s);
	printf("%d",comp[s]);
	return 0;
}
2025/8/4 14:07
加载中...