逍遥北冥 @ 2018-11-16 12:39:30
#include<bits/stdc++.h>
#include<cstring>
using namespace std;
long long t=0,top;
char a[1010];
long long i=0,x,st[1010];
int main()
{
for( t=0; ;t++)
{
a[t]=getchar();
if(a[t]=='@')
{
break;
}
}
while(i<=strlen(a)-2)
{
switch(a[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(a[i]!=' ') x=x*10+a[i++]-'0';
st[++top]=x;break;
}
i++;
}
cout<<st[top];
return 0;
}
by Kisaragi_167 @ 2019-02-27 21:08:27
#include <bits/stdc++.h>
using namespace std;
long long c1[100005];
int main()
{
long long i=0,top=0;
char ch;
while((ch=getchar())!='@')
{
if(ch>='0'&&ch<='9')
{
top*=10;
top+=ch-'0';
}
else if(ch=='.')
{
c1[++i]=top;
top=0;
}
else if(ch=='+')
{
c1[i-1]=c1[i-1]+c1[i];
c1[i]=0;
i--;
}
else if(ch=='-')
{
c1[i-1]=c1[i-1]-c1[i];
c1[i]=0;
i--;
}
else if(ch=='*')
{
c1[i-1]=c1[i-1]*c1[i];
c1[i]=0;
i--;
}
else if(ch=='/')
{
c1[i-1]=c1[i-1]/c1[i];
c1[i]=0;
i--;
}
}
cout<<c1[1];
return 0;
}