// Informatik - Serie 11 - Aufgabe 127
// Program: JavetNoe.cpp
// Autor: Noe Javet (Gruppe P)
// Draw turtle graphics for the Lindenmayer system with
// production F -> F-F++F-F, initial word F++F++F and
// rotation angle 60 degrees.
#include
#include
void y (const unsigned int i);
// POST: the word w_i^F is drawn
void x (const unsigned int i) {
if (i == 0)
ifm::forward(); // F
else {
y(i-1);
ifm::save();
ifm::save();
x(i-1);
ifm::restore();
ifm::left(25);
x(i-1);
ifm::restore();
ifm::left(25);
y(i-1);
ifm::save();
ifm::left(25);
y(i-1);
x(i-1);
ifm::restore();
ifm::right(25);
x(i-1);
}
}
void y(const unsigned int i)
{
if(i==0)ifm::forward();
else
{
y(i-1);
y(i-1);
}
}
int main () {
std::cout << "Number of iterations =? ";
unsigned int n;
std::cin >> n;
// draw w_n = w_n^F++w_n^F++w_n^F
x(n);
return 0;
}