上传者: wzh_xwjh
|
上传时间: 2022-02-22 11:27:15
|
文件大小: 13KB
|
文件类型: -
使用方法:
#include <string h>
#include <stdio h>
#include "DataTypeForBtree h"
#include "BTree h"
struct tree data
{
char tid[37];
char tname[63];
unsigned int aid;
unsigned int id;
};
class CMyDataTypeForBtree : public CDataTypeForBtree
{
public:
virtual void Print void key FILE fp
{
if NULL key || NULL fp
return;
struct tree data tr struct tree data key;
fprintf fp "%u %u %s %s n" tr >id tr >aid tr >tid tr >tname ;
}
virtual int Compare void p1 void p2
{
if NULL p1 || NULL p2
return int unsigned int 0 >> 1 ; 返回一个大点的数表示失败
struct tree data tr1 tr2;
tr1 struct tree data p1;
tr2 struct tree data p2;
if tr2 >aid tr1 >aid
{
return tr1 >aid tr2 >aid;
}
if " 0" tr1 >tid[0] && " 0" tr2 >tid[0]
{
return strcmp tr1 >tname tr2 >tname ;
}
return strcmp tr1 >tid tr2 >tid ;
}
CMyDataTypeForBtree
{
}
virtual CMyDataTypeForBtree
{
}
};
int main int argc char argv[]
{
CMyDataTypeForBtree dt new CMyDataTypeForBtree;
CBTree tree dt 5 ;
struct tree data tr[101] {{"asd" "4Hero" 1 1} {"abc" "Underworld" 1 0} {"bac" "Samantha" 1 2} {"cass" "Gelka" 1 3}
{"mark" "Clark" 1 4} {"gone" "Woolfy" 1 5} {"word" "Production" 1 6} {"paper" "Jimpster" 1 7} {"Richie" "Hawtin" 1 8}
{"John" "Matthias" 1 9} {"Lou" "Donaldson" 1 10} {"Lady" "Alma" 1 11} {"Mass" "Slick" 1 12} {"Clyde" "Alexander" 1 13}
省略若干 省略部分在下载包里面有
{"" "I"M Not Sayin" Get "Er Done But Don"T Just Stand There" 11 101} };
for int i 0; i < 101; i++
{
tree Insert void tr + i ;
}
tree DelKey void tr + 5 ;
tree Traverse NULL NULL ;
tree DelKey void tr + 13 ;
tree Traverse NULL NULL ; 输出到标准输出 可以重定向到文件
return 0;
}">使用方法:
#include <string h>
#include <stdio h>
#include "DataTypeForBtree h"
#include "BTree h"
struct tree data
{
char tid[37];
char tname[63];
unsigned int aid;
unsigned int id; [更多]