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

Theory of Combinatorial Algorithms

Prof. Emo Welzl and Prof. Bernd Gärtner

// Programm: binaer.C // berechnet die Binaerdarstellung einer Dezimalzahl #include #include int main() { // Eingabe std::cout << "Eingabezahl (0 <= zahl <= " << std::numeric_limits::max() << ")" << std::endl; unsigned int zahl; std::cin >> zahl; // Berechnung / Ausgabe std::cout << "Umgekehrte Binaerdarstellung von " << zahl << " ist: "; do { std::cout << zahl % 2; // gib letzte Binaerstelle aus zahl = zahl / 2; // und entferne sie } while (zahl != 0); std::cout << "." << std::endl; return 0; }