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

Theory of Combinatorial Algorithms

Prof. Emo Welzl and Prof. Bernd Gärtner

// Draw Lindenmayer system with turtle graphics // Prog: MoserManuel.cpp // Manuel Moser, 12.12.2011 #include #include //BEST: angle = 75; iterations = 7 (mandala) //another try: angle = 55 ; iterations = 6 (gebiss v. raubfisch) //boring but symmetrical: angle=60; iterations = 6 (gleichs. Dreiecke) //drawing function void doit (const unsigned int i) { int angle=75; if (i == 0) ifm::forward(); else { doit(i-1); ifm::left(angle); doit(i-1); ifm::left(angle); doit(i-1); ifm::left(angle); } } int main () { //iterations std::cout << "Number of iterations =? "; unsigned int n; std::cin >> n; // draw it doit(n); return 0; }