(pwp)为什么有死循环???
查看原帖
(pwp)为什么有死循环???
781722
BoyuZhang楼主2023/5/24 22:09

qwq
本地编译都不行??

#include <iostream>
#include <cstdio>
#include <string.h>
#include <cmath> 
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
using namespace std;
stack<int> stk;
stack<int> stk1;
int main(){
	string m;
	cin>>m;
	char n;
	for(int i=0;i<m.size();i++){
		n=m[i];
		if(n=='@'){
			break;
		}
		else{
			if(n>='0'&&n<='9'){
				stk1.push(n);
			}
			else if(n=='.'){
				int l=0;
				for(int j=0;true;j++){
					if(stk1.empty()){
						break;
					}
					else{
						l+=stk1.top()*pow(j,10);
						stk.pop();
					}
				}
				stk.push(l);
			}
			else{
				int a=stk.top();
				stk.pop();
				int b=stk.top();
				stk.pop();
				if(n=='+'){
					stk.push(a+b);
				}
				else if(n=='-'){
					stk.push(a-b);
				}
				else if(n=='*'){
					stk.push(a*b);
				}
				else{
					stk.push(a/b);
				}
				cout<<i<<endl;
			}
		}
	}
	cout<<stk.top();
	return 0;
}

请各位大佬帮忙看看 pwp

2023/5/24 22:09
加载中...