// Informatik - Serie 11 - Skriptaufgabe 125
// Prog: SchwizerChristoph.cpp
// Author: Christoph Schwizer
// Iterations: 12
// Draw turtle graphics for the Lindenmayer system with
// production F -> F+F+ and initial word F.
#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(50); // +
f(i-1); // w_{i-1}^F
ifm::left(20); // +
}
}
int main () {
std::cout << "Number of iterations =? ";
unsigned int n;
std::cin >> n;
// draw w_n = w_n(F)
f(n);
return 0;
}