## Theory of Combinatorial Algorithms

Prof. Emo Welzl and Prof. Bernd Gärtner

// Prog: DunaiCsaba1.cpp // Draw turtle graphics #include #include #include void rose (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 { rose(i-1, angle); ifm::right(170); rose(i-1, angle); } } // POST: the word w_i^F is drawn void f (const unsigned int i, const double angle) { if (i == 0) { ifm::forward(); ifm::forward(); ifm::forward(); ifm::forward(); ifm::forward(); ifm::forward(); ifm::forward(); ifm::forward(); ifm::forward(); ifm::forward(); rose(5,90); } else { ifm::forward(); ifm::forward(); ifm::forward(); ifm::forward(); ifm::forward(); ifm::forward(); ifm::save(); rose(5,90); ifm::restore(); ifm::forward(); ifm::forward(); ifm::forward(); ifm::forward(); ifm::forward(); ifm::save(); ifm::left(angle); f(i-1, angle); ifm::restore(); ifm::right(angle); f(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<360; ++i){ f(10,15); // } return 0; }