#define LEFT   1
#define BAL    0
#define RIGHT -1

typedef struct avl {
    int value;
    int bal;
    struct avl *left, *right;
} *AVL;

AVL lower (AVL a){
    while ((a.left != NULL) || (a.right != NULL)) {
        if (a.bal = LEFT){
            AVL lower (a.left);
        } else AVL lower (a.right);
    }
    return (a);
}


在这段代码中,我在访问struct内部的struct时遇到问题。
在具有a.lefta.right的地方,该代码应该写什么?谢谢你们。

最佳答案

aAVL,它是指向struct avl的指针。因此,要访问该结构的字段,您需要类似a->left的内容。

关于c - AVL树,结构中的访问指针,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/41854313/

10-11 22:12