为什么用fgets全错了,改成用c++98的gets就对了
#include<bits/stdc++.h>
using namespace std;
int s[309];
char str[309];
void F(char a[])
{
int top=0,i=0,tem=0;
while(i<strlen(a)-2)
{
switch(a[i])
{
case '+':s[--top]+=s[top+1];break;
case '-':s[--top]-=s[top+1];break;
case '*':s[--top]*=s[top+1];break;
case '/':s[--top]/=s[top+1];break;
default :
tem=0;
while(str[i]!='.')
{
tem=tem*10+str[i]-'0';
i++;
}
s[++top]=tem;
}
i++;
}
cout<<s[1];
}
int main()
{
fgets(str,309,stdin);
F(str);
return 0;
}