Admin Admin
Tổng số bài gửi : 84 Points : 117 Thanks : 0 Join date : 06/09/2011 Age : 31 Đến từ : Born From A Bombox
| Tiêu đề: [HELP] Cây nhị phân Thu Oct 20, 2011 9:00 am | |
| Lỗi là " Canot convert from "void" to "NODE *".....ở các dòng tạo nút (CreatNode).. - Code:
-
#include "stdafx.h" struct NODE { int info; NODE *Left,*Right; }; NODE *Root; void CreatNode(int x) { NODE *n=new NODE; n->info=x; n->Left=n->Right=NULL; return n; } void DuyetNLR(NODE *Root) { if(Root!=NULL) { cout<<Root->info; DuyetNLR(Root->Left); DuyetNLR(Root->Right); } } void DuyetLNR(NODE *Root) { if(Root!=NULL) { DuyetLNR(Root->Left); cout<<Root->info; DuyetLNR(Root->Right); } } void DuyetLRN(NODE *Root) { if(Root!=NULL) { DuyetLRN(Root->Left); DuyetLRN(Root->Right); cout<<Root->info; } } int Count(NODE *Root) { if(Root==NULL) return 0; return Count(Root->Left)+Count(Root->Right)+1; } int High(NODE *Root) { int h1,h2; if(Root==NULL) return 0; else { h1=High(Root->Left); h2=High(Root->Right); if(h1>h2) return h1+1; return h2+1; } } void main() { Root=CreatNode(3); Root->Left=CreatNode(7); Root->Left->Left=CreatNode(9); Root->Left->Left->Left=CreatNode(4); Root->Left->Right=CreatNode(6); Root->Left->Right->Left=CreatNode(10); Root->Right=CreatNode(8); Root->Right->Left=CreatNode(2); Root->Right->Right=CreatNode(5); Root->Right->Right->Left=CreatNode(7); cout<<"Duyet truoc N-L-R : "; DuyetNLR(Root); cout<<"\nDuyet giua L-N-R : "; DuyetLNR(Root); cout<<"\nDuyet sau L-R-N : "; DuyetLRN(Root); getch(); } |
|
ThanhTri Member
Tổng số bài gửi : 45 Points : 84 Thanks : 2 Join date : 13/09/2011 Age : 32
| Tiêu đề: Re: [HELP] Cây nhị phân Thu Oct 20, 2011 9:07 am | |
| chuyen~ void CreatNode(int x) thanh` NODE *CreatNode(int x) hehe chep tren bang~ xuong' bi sai ak? |
|