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

Theory of Combinatorial Algorithms

Prof. Emo Welzl and Prof. Bernd Gärtner

// Informatik 2011 - Lindenmayer-Challenge // Program: MiltenbergerKlausUlrich1.cpp // Author: Klaus-Ulrich Miltenberger #include #include // PRE : unsigned integer value n represents the number of iterations // POST : draws the word w_(i^F) void f (char sword, char* production, const int i) { if (i == 0) // draw sword { if (sword == 'F') ifm::forward(); // F if (sword == '+') ifm::left(60); if (sword == '-') ifm::right(60); } else { for (int j = 0; j < 10; ++j) { if (*(production+j) == sword) f(sword, production, i-1); else // draw(*production+j) { if (*(production+j) == 'F') ifm::forward(); // F if (*(production+j) == '+') ifm::left(60); if (*(production+j) == '-') ifm::right(60); } } } } int main() { char sword = 'F'; char production [] = "+FFF-FFF+F"; int n; std::cout << "\n Number of iterations : n = "; // n = 9 suggested... (could take a minute to draw!) std::cin >> n; f(sword, production, n); return 0; }