由比滨丶雪乃 @ 2019-07-20 14:54:40
#include <iostream>
#include <cstdlib>
#include <cstring>
using namespace std;
int stack[101];
char s[256];
int main()
{
cin>>s;
int i=0,top=0,x,y;
while(s[i]!='@')
{
switch(s[i])
{
case'+':stack[--top]+=stack[top+1];break;
case'-':stack[--top]-=stack[top+1];break;
case'*':stack[--top]*=stack[top+1];break;
case'/':stack[--top]/=stack[top+1];break;
case'.':stack[++top]=x;x=0;;break;
default:x=x*10+s[i]-'0';break;
}
i++;
}
cout<<stack[top]<<endl;
return 0;
}
by HZAUqzx @ 2019-07-30 18:51:27
@由比滨丶雪乃
我给你小改了一下就好了
R21841589 记录详情
#include <iostream>
#include <cstdlib>
#include <cstring>
using namespace std;
int stack[1010];
char s[1010];
int main()
{
cin>>s;
int i=0,top=0,x=0,y;
while(s[i]!='@')
{
switch(s[i])
{
case'+':stack[--top]+=stack[top+1];break;
case'-':stack[--top]-=stack[top+1];break;
case'*':stack[--top]*=stack[top+1];break;
case'/':stack[--top]/=stack[top+1];break;
case'.':stack[++top]=x;x=0;;break;
default:x=x*10+s[i]-'0';break;
}
i++;
}
cout<<stack[top]<<endl;
return 0;
}
两个简单的初始化错误
不客气
by 由比滨丶雪乃 @ 2019-07-30 19:19:36
谢谢了QWQ@1700qiaozixuan
by btc001 @ 2019-08-15 20:48:02
橙名大佬!%%%