//Informatik - Serie 11 - C.A. 127
//Autor: Tram Anh Duong
//Program: DuongTram1.cpp
#include
#include
//PRE: unsigned int i, which is the number of iterations
//POST: jumps if i == 0, calls f(i) otherwise
void j(const unsigned int i);
//PRE: unsigned int i, which is the number of iterations
//POST: the word w_i^F is drawn
void f(const unsigned int i) {
if (i==0)
ifm::forward();
else {
f(i-1);
ifm::left(60);
f(i-1);
ifm::right(120);
f(i-1);
ifm::left(60);
f(i-1);
ifm::right(120);
f(i-1);
ifm::left(60);
f(i-1);
ifm::right(120);
f(i-1);
ifm::left(60);
f(i-1);
ifm::right(120);
f(i-1);
ifm::left(60);
f(i-1);
ifm::right(120);
f(i-1);
ifm::left(60);
f(i-1);
ifm::save();
ifm::left(90);
j(i-1);
ifm::restore();
ifm::right(90);
j(i-1);
}
}
void j(const unsigned int i) {
if (i==0) {
ifm::jump();
} else
f(i);
}
int main() {
std::cout<<"Number of iterations= (1, 3 or 4 recommended ;-) )?";
unsigned int n;
std::cin>>n;
//draw w_n=w_n(F)
f(n);
return 0;
}