小编Luk*_*těk的帖子

有没有一种方法可以缩短这种情况?

while (temp->left->oper == '+' || 
       temp->left->oper == '-' || 
       temp->left->oper == '*' || 
       temp->left->oper == '/' || 
       temp->right->oper == '+' || 
       temp->right->oper == '-' || 
       temp->right->oper == '*' || 
       temp->right->oper == '/')
{
    // do something
}
Run Code Online (Sandbox Code Playgroud)

为了清楚起见:temp是一个指向以下node结构的指针:

struct node
{
    int num;
    char oper;
    node* left;
    node* right;
};
Run Code Online (Sandbox Code Playgroud)

c++ algorithm if-statement while-loop simplify

50
推荐指数
6
解决办法
6566
查看次数

标签 统计

algorithm ×1

c++ ×1

if-statement ×1

simplify ×1

while-loop ×1