为啥不开O2就能过,开O2直接RE??
查看原帖
为啥不开O2就能过,开O2直接RE??
272945
asdfo123楼主2020/9/27 13:33

不开O2O_2 就能过

O2O_2RERE

#include <bits/stdc++.h>
#define int long long
using namespace std;
const int maxn = 1010;
char c[maxn];
int st[maxn];
bool comp(char *c)
{
	int i = 0;
	int now = 0;
	int top = 0;
	while(c[i]!='@')
	{
		if(c[i]>='0' && c[i]<='9')
		{
			now*=10;
			now+=c[i] - '0';
		}
		else if(c[i] == '.') 
		{
			st[++top] = now;
			now = 0;
		}
		else if(c[i] == '+')
		{
			st[top-1] = st[top-1] + st[top];
			st[top] = 0;
			top--;
		}
		else if(c[i] == '-')
		{
			st[top-1] = st[top-1] - st[top];
			st[top] = 0;
			top--;
		}
		else if(c[i] == '*')
		{
			st[top-1] = st[top-1] * st[top];
			st[top] = 0;
			top--;
		}
		else if(c[i] == '/')
		{
			st[top-1] = st[top-1] / st[top];
			st[top] = 0;
			top--;
		}
		i++;
	}	
}			
signed main()
{
	scanf("%s",c);
	comp(c);
	printf("%lld\n",st[1]);
	return 0;
}
2020/9/27 13:33
加载中...