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

Theory of Combinatorial Algorithms

Prof. Emo Welzl and Prof. Bernd Gärtner

// IFMP - Serie 11 - Skript-Aufgabe 137 (Challenge) // Progamm: NaegelinMara.cpp // Draw turtle graphics for some Lindenmayer system // (works best with 6 iterations) // Autor: M. NŠgelin #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::right(30); f(i-1); ifm::left(30); f(i-1); ifm::right(30); f(i-1); ifm::left(30); f(i-1); ifm::right(30); f(i-1); ifm::forward(); ifm::save(); ifm::forward(); ifm::left(10); f(i-1); ifm::restore(); ifm::left(35.5); } } int main () { std::cout << "Number of iterations =? "; unsigned int n; std::cin >> n; // draw w_n = w_n^F ifm::left(90); f(n); // w_n^F return 0; }