B树的C++源代码及测试代码

上传者: 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; [更多]

文件下载

评论信息

  • bobo5582191 :
    部分文件不是unicode格式,如果vs采用unicode编码格式需要手动转换一下;可以用,写的不错
    2017-12-18
  • gcg930318 :
    注释挺详细的
    2016-02-26
  • zhengsyou :
    代码还不错,感谢分享!
    2015-10-06
  • u011514820 :
    代码写得不怎么样
    2015-07-16
  • u012953303 :
    注释挺详细的
    2014-12-11

免责申明

【只为小站】的资源来自网友分享,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,【只为小站】 无法对用户传输的作品、信息、内容的权属或合法性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论 【只为小站】 经营者是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。
本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二条之规定,若资源存在侵权或相关问题请联系本站客服人员,zhiweidada#qq.com,请把#换成@,本站将给予最大的支持与配合,做到及时反馈和处理。关于更多版权及免责申明参见 版权及免责申明