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: MiltenbergerKlausUlrich2.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(30); if (sword == '-') ifm::right(30); } 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(30); if (*(production+j) == '-') ifm::right(60); } } } } int main() { char sword = 'F'; char production [] = "-F+F-F-F--"; int n; std::cout << "\n Number of iterations : n = "; // n = 9 suggested... std::cin >> n; f(sword, production, n); return 0; }