Last active
June 11, 2020 21:52
-
-
Save niklasbuschmann/b49ec417f4c60ca1f183ad20a6595337 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
struct rechteck { | |
double x, y; | |
}; | |
rechteck rotation(rechteck r) { | |
rechteck rot = {r.y, r.x}; | |
return rot; | |
} | |
bool bedeckt(rechteck r1, rechteck r2) { | |
return r1.x >= r2.x && r1.y >= r2.y; | |
} | |
int main() { | |
cout << "Rechteckstuct" << endl; | |
rechteck r1 = {3.3, 2.0}; | |
rechteck r2 = {1.8, 2.7}; | |
cout << "Vor Rotation: "; | |
if (bedeckt(r1,r2)) cout << "r1 bedeckt r2."; | |
else cout << "r1 bedeckt r2 nicht."; | |
cout << endl; | |
r2 = rotation(r2); | |
cout << "Nach Rotation: "; | |
if (bedeckt(r1,r2)) cout << "r1 bedeckt r2."; | |
else cout << "r1 bedeckt r2 nicht."; | |
cout << endl; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
void print(string origin, string target) { | |
cout << "Lege oberste Scheibe von Stapel " << origin << " auf Stapel " << target << endl; | |
} | |
void hanoi(int n, string origin, string target, string temp) { | |
if (!n) return; | |
hanoi(n - 1, origin, temp, target); | |
print(origin, target); | |
hanoi(n - 1, temp, target, origin); | |
}; | |
int main(int argc, char** argv) { | |
if (argc > 1) | |
hanoi(*argv[1] - '0', "A", "B", "C"); | |
else | |
cout << "run with n as first argument" << endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment