Knocker和90后和脑残有什么关系?
RTRTRTRT

程序代码:
#include<stdio.h>
#include<string.h>
#define push1(X) (stack_1[++pstack_1]=X)
#define pop1() (stack_1[pstack_1--])
#define top1() (stack_1[pstack_1])
#define push2(X) (stack_2[++pstack_2]=X)
#define pop2() (stack_2[pstack_2--])
#define top2() (stack_2[pstack_2])
int stack_1[1000];
double stack_2[1000];
int pstack_1=-1;
int pstack_2=-1;
char str_1[2000],str_2[2000],pstr_2=0;
void buildstr()
{
int i=0;
char t;
while(str_1[i])
{
if(str_1[i]>='0' && str_1[i]<='9')
{
while(str_1[i]>='0' && str_1[i]<='9')
{
str_2[pstr_2++]=str_1[i++];
}
str_2[pstr_2++]='.';
continue;
}
switch(str_1[i])
{
case '(': push1('('); break;
case ')': while((t=pop1())!='(') str_2[pstr_2++]=t; break;
case '*':
case '/':
while(pstack_1>=0 && ((t=top1())=='*' || t=='/'))
{
str_2[pstr_2++]=pop1();
}
push1(str_1[i]); break;
case '+':
case '-':
while(pstack_1>=0 && ((t=top1())!='('))
{
str_2[pstr_2++]=pop1();
}
push1(str_1[i]);
}
i++;
}
while(pstack_1>=0)
{
str_2[pstr_2++]=pop1();
}
str_2[pstr_2]=0;
}
void calculate()
{
int i=0;
double x,y;
while(str_2[i])
{
if(str_2[i]>='0' && str_2[i]<='9')
{
double count=0;
while(str_2[i]!='.')
{
count*=10;
count+=str_2[i++]-'0';
}
push2(count);
}
else
{
y=pop2();
x=pop2();
switch(str_2[i])
{
case '+': push2(x+y); break;
case '-': push2(x-y); break;
case '*': push2(x*y); break;
case '/': push2(x/y);
}
}
i++;
}
}
int main(void)
{
while(scanf("%s",str_1)!=EOF)
{
buildstr();
calculate();
printf("%.3f\n",pop2());
}
return 0;
}
