?? algo9-5.cpp
字號:
// algo9-5.cpp 檢驗bo9-3.cpp的程序
#include"c1.h"
#define N 5 // 數據元素個數
typedef char KeyType; // 設關鍵字域為字符型
struct ElemType // 數據元素類型
{
KeyType key;
int order;
};
#include"c9.h"
#include"c9-2.h"
#include"bo9-3.cpp"
void print(ElemType c)
{
printf("(%d,%d)",c.key,c.order);
}
void main()
{
BSTree dt,p;
Status k;
int i;
KeyType j;
ElemType r[N]={{13,1},{24,2},{37,3},{90,4},{53,5}}; // (以教科書圖9.12為例)
InitDSTable(dt); // 初始化空樹
for(i=0;i<N;i++)
InsertAVL(dt,r[i],k); // 建平衡二叉樹
TraverseDSTable(dt,print); // 按關鍵字順序遍歷二叉樹
printf("\n請輸入待查找的關鍵字: ");
scanf("%d",&j);
p=SearchBST(dt,j); // 查找給定關鍵字的記錄
if(p)
print(p->data);
else
printf("表中不存在此值");
printf("\n");
DestroyDSTable(dt);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -