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

Theory of Combinatorial Algorithms

Prof. Emo Welzl and Prof. Bernd Gärtner

//Program: HitzCarola2.cpp //Autor: Carola Hitz Student // Draw turtle graphics for the Lindenmayer system #include #include void y (const unsigned int i); // POST: the word w_i^F is drawn void f (const unsigned int i) { if (i == 0) ifm::forward(); // F else { f(i-1); // w_{i-1}^F ifm::left(120); // + f(i-1); // w_{i-1}^F ifm::left(120); // + }} // POST: w_i^Y is drawn void y (const unsigned int i) { if (i > 0) { ifm::right(60); // - ifm::forward(); // F f(i-1); // w_{i-1}^F ifm::right(60); // - y(i-1); // w_{i-1}^Y } } int main () { unsigned int n = 15; // draw w_n = w_n(F) y(n); return 0; }