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 - Aufgabe 127 //Autor: Karim el Haqyawan //Prog: ElHqayawanKarim1.cpp //Draw turtle graphics for the Lindenmayer system with //production F -> [+][+F][-F]F #include #include // POST: the word w_i^F is drawn void f (const unsigned int i) { if (i == 0) ifm::forward(); // F else { ifm::forward(1); ifm::save(); //[ ifm::right(150); //+ ifm::forward(1); ifm::restore(); //] ifm::save(); //[ ifm::right(30); //+ ifm::forward(1); f(i-1); //w_{i-1}^F ifm::restore(); //] ifm::save(); //[ ifm::left(30); //- ifm::forward(1); f(i-1); //w_{i-1}^F ifm::restore(); //] ifm::forward(1); f(i-1); //w_{i-1}^F } } int main () { std::cout << "Number of iterations =? "; unsigned int n; std::cin >> n; // draw w_n = w_n(F) f(n); return 0; }