Return to Snippet

Revision: 68495
at January 19, 2015 05:29 by mateom11


Initial Code
#include<iostream>
#include "prvo dijete-sljedeci brat.h"
using namespace std;

void Preorder(int t, tree *T){    
	cout <<t<<"  ";
	if(FirstChildT(t,T)!=-1) 
		Preorder(FirstChildT(t,T),T);
 
	if(NextSiblingT(t,T)!=-1)
		Preorder(NextSiblingT(t,T),T);
}
 
void Inorder(int t,tree *T){
	if (FirstChildT(t,T)!=-1)
	Inorder(FirstChildT(t,T),T);
	cout <<t<<"  ";
	if(FirstChildT(t,T)!=-1){
		t=FirstChildT(t,T);
		while(NextSiblingT(t,T)!=-1){
			t=NextSiblingT(t,T);
			Inorder(t,T);
		}
	}
}
 
void Postorder(int t,tree *T){
	if(FirstChildT(t,T)!=-1)
		Postorder(FirstChildT(t,T),T);
		int pomkorijen=t;
	if(FirstChildT(pomkorijen,T)!=-1){
		pomkorijen=FirstChildT(pomkorijen,T);
		while(NextSiblingT(pomkorijen,T)!=-1){
			pomkorijen=NextSiblingT(pomkorijen,T);
			Postorder(pomkorijen,T);
		}
	}
	cout<<t<<"  ";
}

Initial URL

                                

Initial Description
Ophodnja_stabla

Initial Title
Ophodnja_stabla.h

Initial Tags

                                

Initial Language
C++