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

Theory of Combinatorial Algorithms

Prof. Emo Welzl and Prof. Bernd Gärtner

// Informatik - Lindenmayer Challenge // Programm: MayrhoferLukas.cpp // Autor: Lukas Mayrhofer // Draw turtle graphics for the Lindenmayer system with // productions F -> +F-GG-F+, G -> +G+G, initial word F // and rotation angle 60 degrees #include #include // POST: w_i^G is drawn void g (const unsigned int i) { if (i == 0) ifm::forward(); else { ifm::left(60); // + g(i-1); // w_{i-1}^G ifm::left(60); // + g(i-1); // w_{i-1}^G } } // POST: w_i^F is drawn void f (const unsigned int i) { if (i == 0) ifm::forward(); else { ifm::left(60); // + f(i-1); // w_{i-1}^F ifm::right(60); // - g(i-1); // w_{i-1}^G g(i-1); // w_{i-1}^G ifm::right(60); // - f(i-1); // w_{i-1}^F ifm::left(60); // + } } int main () { std::cout << "Number of iterations =? "; unsigned int n; std::cin >> n; // draw w_n = w_n^X f(n); return 0; }