Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- typedef int nodetypet;
- #include "opcenitoP.h"
- typedef nodet elementtypeq;
- using namespace std;
- void obrisi(tree &T, nodet n){
- }
- void PrO(tree &T, nodet n){
- cout << n -> label << ", ";
- if (FirstChildT(T, n) != lambdat)
- PrO(T, FirstChildT(T, n));
- if (NextSiblingT(T, n) != lambdat)
- PrO(T, NextSiblingT(T, n));
- }
- void Preorder(tree &T) {
- PrO(T, RootT(T));
- }
- int main(){
- nodet n;
- tree T;
- InitT(T, 4);
- n=RootT(T);
- CreateChildT(T, n, 7);
- CreateChildT(T, n, 6);
- CreateChildT(T, n, 8);
- n=FirstChildT(T,n);
- CreateChildT(T, n, 2);
- CreateChildT(T, n, 8);
- n=FirstChildT(T, n);
- CreateChildT(T, n, 3);
- n=NextSiblingT(T, n);
- CreateChildT(T, n, 1);
- n=ParentT(T,n);
- n=NextSiblingT(T, n);
- n=NextSiblingT(T, n);
- CreateChildT(T, n, 5);
- n=FirstChildT(T, n);
- CreateChildT(T, n, 9);
- CreateChildT(T, n, 2);
- Preorder(T);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement