9.32.txt

来自「数据结构实验 如下: Status Fibonacci(int k, int」· 文本 代码 · 共 25 行

TXT
25
字号
void Out_X(BiTree t, KeyType x, KeyType &a, KeyType &b,int &last);

void OutX(BiTree t, KeyType x, KeyType &a, KeyType &b)
/* a: Return the nearest and smaller value to x, */
/*    but return MINV if no the value in t.      */
/* b: Return the nearest and larger  value to x. */
/*    but return MAXV if no the value in t.      */
{
    int last = 0;
    a = b = 0;
    Out_X(t, x, a, b, last);
    if(a == 0) a = MINV;
    if(b == 0) b = MAXV;
}


void Out_X(BiTree t, KeyType x, KeyType &a, KeyType &b,int &last)
{
    if(t->lchild) Out_X(t->lchild, x, a, b, last);
    if(last < x && t->data.key >= x) a = last;
    if(last <= x&& t->data.key > x) b = t->data.key;
    last = t->data.key;
    if(t->rchild) Out_X(t->rchild, x, a, b, last);
    else if( last < x) a = last;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?