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

Theory of Combinatorial Algorithms

Prof. Emo Welzl and Prof. Bernd Gärtner

//Blume und Seepferdchen von Maximilian Feil, //B wird mit n=8 aufgerufen, S wird mit n=3 aufgerufen #include #include #include void B(const unsigned int k){ if(k == 0) ifm::forward(); else { ifm::left(90); B(k-1); ifm::save(); ifm::save(); ifm::right(45); B(k-1); ifm::jump(); B(k-1); ifm::restore(); ifm::left(45); B(k-1); ifm::jump(); B(k-1); } } void S(const unsigned int k){ if(k == 0) ifm::forward(); else { S(k-1); ifm::left(30); S(k-1); ifm::left(40); S(k-1); ifm::left(50); S(k-1); ifm::left(60); S(k-1); ifm::left(70); S(k-1); ifm::left(80); S(k-1); ifm::left(90); S(k-1); ifm::left(100); S(k-1); ifm::left(110); S(k-1); ifm::left(120); S(k-1); ifm::left(130); S(k-1); ifm::left(140); S(k-1); ifm::jump(); } } int main() { //Input unsigned int n = 0; std:: cout << "------------------------------------------------------------\n" << "Es gibt zwei Lindenmayersysteme. \nGeben Sie <1> ein, um eine <> zu erhalten.\nGeben Sie <2> ein, um ein <> zu erhalten.\n"; std:: cin >> n; assert(n == 1 || n == 2); if(n ==1) B(8); else S(3); return 0;}