但还是要吐槽下百练OJ,明明上面提示人家用cmath,结果G++不认介个。。CE = =
然后改cstdlib过了 = =
难道要用GCC? = =!!
#include"cstdio"
#include"cstdlib"
double func()
{
char s[20];
double a,b;
scanf("%s",s);
switch(s[0]){
case '+': return func() + func();
case '-': return func() - func();
case '*': return func() * func();
case '/': a = func(),b = func();
if(b) return a / b;
else return -1; //这里return什么好。。。好像-1也不妥= =
default : return atof(s);
}
}
int main()
{
printf("%lf\n",func());
}
没有评论:
发表评论