Ejemplo n.º 1
0
BaseMesh* BoolOp::Execute(std::vector<BaseMesh*>& meshList, const std::string& expression)
{
    if (meshList.size() == 0)
        return NULL;
    // Parser expression 
    std::string postfix = InfixToPostfix(expression);
    return Evalute(meshList, postfix);
    
}
Ejemplo n.º 2
0
int main(int argc, const char * argv[])
{
    string infix,postfix;
    double result;
    cout<<"Enter an infixed expression:- ";
    cin>>infix;
    postfix=InfixToPostfix(infix);
    cout<<"\nPostfix expression:- "<<postfix;
    result=postfixEvaluation(postfix);
    cout<<"\nResult evaluation:- "<<result;
    return 0;
}
Ejemplo n.º 3
0
int main(int argc,char *argv[])
{
    printf("请输入中缀表达式:\n"); //输入中缀表达式。
    char src[BUFFERSIZE]={'\0'}; //存放中缀表达式的临时缓冲区
    char *infix=src;
    char postfix[BUFFERSIZE]={'\0'}; //存放后缀表达式的临时缓冲区
    fgets(infix,BUFFERSIZE,stdin); //从标准输入流中读取要计算的四则运算表达式
    printf("中缀表达式为:%s",infix);
    InfixToPostfix(infix,postfix); //将中缀转换为后缀表达式
    printf("后缀表达式为:%s\n",postfix);
    double result;
    CalculatePostfix(postfix,&result); //计算后缀表达式的结果
    printf("计算结果为:%f\n",result);

    return 0;
}