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 - Challenge 125 // Program: BuddeKai1.cpp // Author: Kai Budde // Draw an amazing picture (this case: "Ugly Flower") #include #include // PRE: Please enter n==6 // POST: A rather ugly looking flower is drawn void f (const unsigned int i) { if (i == 0) ifm::forward(); // F else { f(i-1); ifm::forward(); ifm::save(); ifm::left(30); ifm::forward(2); f(i-1); ifm::restore(); ifm::save(); ifm::right(60); ifm::forward(2); f(i-1); ifm::restore(); } } int main () { std::cout << "Number of iterations =? "; unsigned int n; std::cin >> n; // draw the picture ifm::left(90); ifm::forward(10); f(n); return 0; }