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 - Skriptaufgabe 125 // Prog: GehrigManuela.cpp // Author: Manuela Gehrig // Draw turtle graphics for the Lindenmayer system with // productions X -> X+YF+, Y -> -FX-Y, initial word X // and rotation angle 90 degrees #include #include void y (const unsigned int i); void z (const unsigned int i); // POST: w_i^X is drawn void x (const unsigned int i) { if (i > 0) { ifm::forward(); z(i); ifm::right(90); y(i-1); } } void y (const unsigned int i) { if (i > 0) { ifm::forward (); ifm::right (90); z(i); x(i-1); ifm::forward(); ifm::left (90); x(i-1); } } void z (const unsigned int i) { if (i > 0) { ifm::left(60); ifm::forward(); ifm::right (60); } } int main () { std::cout << "Number of iterations =? "; unsigned int n; std::cin >> n; // draw w_n = w_n^X x(n); return 0; }