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

Theory of Combinatorial Algorithms

Prof. Emo Welzl and Prof. Bernd Gärtner

// Prog: VetterSilvan.cpp // Draw turtle graphics for the Lindenmayer system #include #include void f (const unsigned int i); void l (const unsigned int i){ if (i == 0) ifm::forward(); else { l(i-1); f(i-1); ifm::right(45); l(i-1); ifm::right(45); l(i-1); ifm::right(45); ifm::jump(10); f(i-1); ifm::right(45); l(i-1); ifm::right(45); f(i-1); ifm::right(45); } } // 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(45); ifm::jump(3); f(i-1); ifm::save(); l(i-1); f(i-1); ifm::left(45); f(i-1); ifm::left(45); f(i-1); ifm::restore(); ifm::left(45); l(i-1); ifm::left(45); } } int main () { std::cout << "Number of iterations =? Five iterations are ideal!"; unsigned int n; std::cin >> n; l(n); ifm::right(30); l(n); ifm::right(30); l(n); ifm::right(30); l(n); ifm::right(30); l(n); ifm::right(30); l(n); ifm::right(30); l(n); ifm::right(30); l(n); ifm::right(30); l(n); ifm::right(30); l(n); ifm::right(30); l(n); ifm::right(30); l(n); return 0; }