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

Theory of Combinatorial Algorithms

Prof. Emo Welzl and Prof. Bernd Gärtner

// Serie 11 - Challenge Aufgabe // Author: Florian Johne Gruppe E // Prog: JohneFlorian.cpp // Draw turtle graphics for the Lindenmayer system with // production F -> FlFlFr and initial word F+F-. // n = 10, 12 #include #include // POST: the word w_i^F is drawn void f (const unsigned int i) { if (i == 0) ifm::forward(); else { f(i-1); ifm::left(1); f(i-1); ifm::left(1); f(i-1); ifm::right(3); } } int main () { std::cout << "Number of iterations =? "; unsigned int n; std::cin >> n; // draw Lindenmayer turtle graphics f(n); ifm::left(60); f(n); ifm::right(60); return 0; }