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

Theory of Combinatorial Algorithms

Prof. Emo Welzl and Prof. Bernd Gärtner

// Programm: subtract.C // Teste Subtraktion zweier Fliesskommazahlen #include int main() { // Eingabe std::cout << "Subtraktions-Test\nminuend =? "; float minuend; std::cin >> minuend; std::cout << "subtrahend =? "; float subtrahend; std::cin >> subtrahend; std::cout << minuend << " - " << subtrahend << " =? "; float result; std::cin >> result; // Berechnung des "korrekten" Ergebnisses float real_result = minuend - subtrahend; // Vergleiche beide Ergebnisse und gib // die Beurteilung aus: if (result == real_result) std::cout << "korrekt." << std::endl; else std::cout << "Falsch, um " << real_result - result << " daneben." << std::endl; return 0; }