// Informatik - Serie 11 - Challenge 125
// Autor: Pierre Boutinard Rouelle
// Prog: BoutinardRouellePierre.cpp
// Draw turtle graphics for the Lindenmayer system with
// production F -> F+F-F-F+F and initial word F.
// With 5 steps.
#include
#include
// POST: the word w_i^F is drawn
void f (const unsigned int i) {
if (i == 0)
ifm::forward(); // F
else {
f(i-1); // w_{i-1}^F
ifm::left(80); // +
f(i-1); // w_{i-1}^F
ifm::right(80); // -
f(i-1); // w_{i-1}^F
ifm::right (80); //-
f(i-1); // w_{i-1}^F
ifm::left(80); //+
f(i-1); // w_{i-1}^F
}
}
int main () {
std::cout << "Number of iterations =? ";
unsigned int n;
std::cin >> n;
// draw w_n = w_n(F)
f(n);
return 0;
}