## Theory of Combinatorial Algorithms

Prof. Emo Welzl and Prof. Bernd Gärtner

// Prog: DunaiCsaba4.cpp // Draw turtle graphics #include #include void g (const unsigned int i, const unsigned int angle) { if (i == 0) { ifm::forward(); ifm::right(angle); ifm::forward(); ifm::left(angle); ifm::forward(); ifm::right(angle); ifm::forward(); ifm::right(180); ifm::forward(); ifm::right(angle); ifm::forward(); ifm::left(angle); ifm::forward(); ifm::right(angle); ifm::forward(); } else { g(i-1, angle); ifm::right(170); g(i-1, angle); } } // POST: the word w_i^F is drawn void f (const unsigned int i, const unsigned int angle) { if (i == 0) { ifm::forward(2); ifm::right(angle); ifm::forward(2); ifm::left(angle); ifm::forward(2); ifm::right(angle); ifm::forward(2); ifm::right(180); ifm::forward(2); ifm::right(angle); ifm::forward(2); ifm::left(angle); ifm::forward(2); ifm::right(angle); ifm::forward(2); } else { f(i-1, angle); ifm::save(); g(i, angle); ifm::restore(); ifm::right(170); f(i-1, angle); } } void h (const unsigned int i, const unsigned int angle) { if (i == 0) { ifm::forward(10); ifm::right(angle); ifm::forward(10); ifm::left(angle); ifm::forward(10); ifm::right(angle); ifm::forward(10); ifm::right(180); ifm::forward(10); ifm::right(angle); ifm::forward(10); ifm::left(angle); ifm::forward(10); ifm::right(angle); ifm::forward(10); } else { h(i-1, angle); ifm::save(); f(i, angle); ifm::restore(); ifm::right(170); h(i-1, angle); } } int main () { std::cout << "Number of iterations =? "; unsigned int n; //std::cin >> n; std::cout << "Angle =? "; unsigned int a; //std::cin >> a; // draw w_n = w_n(F) // for(int i=1; i<36; ++i){ h(10,90); // g(10,90); // } return 0; }