Creating a tree and showing tree

xiaoxiao2021-03-05  20

/ * a00 | __B01 | | __D02 | | | __F03 | | | | __G13 | | __E12 | __C11 * / # include #include #define max 10using name; class node; Class Node; {Friend Class Table; INT INEXTNUM; INT INEXTNUM; Node * PNext [MAX]; INT IPRIZE; IX; INT IY; Public: Node () {COUT << "Sname:"; CIN >> SNAME; COUT < <"inextnum:"; cin >> inextNum; cout << '/ n';}};

Class table {private: node * pfirst; void createtable (node ​​*); public: void print (node ​​*); void table :: print0 (node ​​*); node * first () {Return Pfirst;} Table () {PFirst = new node; pfirst-> ix = 0; pfirst-> = 0; CreateTable (pfirst);}}; void table :: createtable (node ​​* p) {INT i; if (p-> inextnum! = 0) {For (i = 0; i inextNum; i ) {p-> pnext [i] = new node; (p-> pnext [i]) -> ix = i; (p-> pnext [i ]) -> = p-> iy 1; CreateTable (p-> pnext [i]);} for (i = p-> inextnum; i pnext [i] = null }}} Else {for (i = 0; i pnext [i] = null;}}} void Table :: Print0 (Node * P) {} void Table :: Print (Node * P) {INT i; cout << p-> sname << '(' << p-> ix << ',' << p-> xi << ')' << ','; if (p -> INEXTNUM! = 0 ) {For (i = 0; i inextNum; i ) {print (p-> pnext [i]);}} else {}}}} else}}}}}} else}}}}} else}}}}} else}}}}}} else}}}}}}} else}}}}}} else}}}}}}} else}}}}}} else}}}}}}} else {}} int Main (int Argc, char * argv []) {Table Table Table.Print (Table.First ()); table.print0 (Table.First ()); system ("pause"); return 0;}

转载请注明原文地址:https://www.9cbs.com/read-39325.html

New Post(0)