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

Theory of Combinatorial Algorithms

Prof. Emo Welzl and Prof. Bernd Gärtner

// Prog: GebhardMarcel.cpp // Draw turtle graphics for the Lindenmayer system with // production F -> F+[FFF-F]-[F-F]F, initial word F and // rotation angle 60 degrees. #include #include // POST: the word w_i^F is drawn void f (const unsigned int i) { if (i == 0) ifm::forward(2); // F else { f(i-1); // w_{i-1}^F ifm::left(60); // + ifm::save(); // [ f(i-1); // w_{i-1}^F f(i-1); // w_{i-1}^F f(i-1); // w_{i-1}^F ifm::right(60); // - f(i-1); // w_{i-1}^F ifm::restore; // ] ifm::right(60); // - ifm::save(); //[ f(i-1); // w_{i-1}^F ifm::right(60); // - f(i-1); // w_{i-1}^F ifm::restore; // ] f(i-1); // w_{i-1}^F } } int main () { std::cout << "Number of iterations =? "; unsigned int n; std::cin >> n; f(n); // w_n^F return 0; }