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 - Aufgabe 127 // Programm: VischerLucas3.cpp // Autor: L. Vischer // 6 iterations are recommended. #include #include void f(unsigned int i, int t) { if (i == 0) ifm::forward(1); else { f(i-1,t); ifm::left(60*t); f(i-1,t); ifm::right(120*t); f(i-1,t); ifm::left(60*t); f(i-1,t); } } void g(unsigned int i, int t) { if (i == 0) ifm::forward(5); else { g(i-1,t); ifm::left(60*t); g(i-1,t); ifm::right(60*t); g(i-1,t); ifm::right(60*t); g(i-1,t); ifm::left(60*t); g(i-1,t); } } int main() { std::cout << "Number of iterations?\n"; unsigned int n; std::cin >> n; int t = 1; ifm::left(30); for (unsigned int a=1;a<=2*n;++a) { if (a == n+1) t = -1; ifm::save(); ifm::right(60*(a-1)); f(n,t); ifm::restore(); ifm::save(); ifm::right(60*(a-1)); for (int x=1;x<=8;++x) g(2,t); ifm::restore(); ifm::save(); ifm::right(30+a*60); for (int x=1;x<=3;++x) g(2,t); ifm::restore(); } return 0; }