求助大佬,五个RE!!!真的快哭了
查看原帖
求助大佬,五个RE!!!真的快哭了
1257536
S1417830194楼主2024/3/11 21:50
#include <iostream>
#include <stack>
using namespace std;

stack<long long> number;

int main()
{
	long long temp=0;char ch;
	bool flag=false;
	while( ( ch=getchar() )!='\n')
	{
		if(flag && ch>='0' && ch<='9' )
		{
			temp*=10;temp+=ch-'0';continue;
		}
		if(ch=='.')
		{
			number.push(temp);flag=false;temp=0;
			continue;
		}
		else if(ch>='0' && ch<='9')
		{
			temp=ch-'0';flag=true;
			continue;
		}
		else if(ch=='@')
			cout<<number.top();
		else
		{
			int A=number.top(); number.pop();//删去该pop语句和下面的pop语句会出现五个TLE
			int B=number.top(); number.pop();
	
			switch(ch)
			{
				case '*': 
					number.push(A*B);break;
				case '/': 
					number.push(B/A);break;
				case '+': 
					number.push(A+B);break;
				case '-':  
					number.push(B-A);break;
			}
		}
			
	}
	
	return 0;
}

2024/3/11 21:50
加载中...