Department of Computer Science | Institute of Theoretical Computer Science | CADMO

Theory of Combinatorial Algorithms

Prof. Emo Welzl and Prof. Bernd Gärtner

//Informatik - Serie 11 - Challenge //Programm: PatrickPietsch.C //Autor: Patrick Pietsch (Gruppe H) //Beschreibung: Diese Programm zeichnet einen Baum. #include #include using namespace std; using namespace ifm; void w (int n)//Ast waechst, Laenge von Position im Baum abhaengig { forward (n); } void k (int n)//Neue Veraestelung, Winkel abhaengig vom "Zufall" { if (n!=0) { save(); left(rand()%81-40); w(n-1); save(); left(rand()%81-40); w(n-1); k(n-1); restore(); k(n-1); restore(); if (rand()%2==0) { save(); right(rand()%81-40); w(n-1); k(n-1); restore(); } right(rand()%81-40); w(n-1); save(); k(n-1); restore(); left(rand()%81-40); w(n-1); k(n-1); } } int main()//Hauptfunktion { int n; cout<<"Diese Programm zeichnet einen Baum. Bitte geben Sie die Anzahl der Iterationsschritte ein:\n"; cin >> n; left (90); w(n); k(n); return 0; }