Department of Computer Science | Institute of Theoretical Computer Science | CADMO

Theory of Combinatorial Algorithms

Prof. Emo Welzl and Prof. Bernd Gärtner

//Informatik - Serie 11 - C.A. 127 //Autor: Tram Anh Duong //Program: DuongTram2.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::left(90); j(i-1); ifm::left(90); j(i-1); ifm::left(90); j(i-1); ifm::left(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; }