lundi 22 juillet 2019

Is there way to shorten this while condition?

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
}

for clarity temp is pointer that points to this structure:

struct node{
    int num;
    char oper;
    node* left;
    node* right;
};

Aucun commentaire:

Enregistrer un commentaire