fork download
  1. #include <iostream>
  2. using namespace std;
  3. int main() {
  4. for (double a, b; cin >> a >> b; ) {
  5. cout << "a=" << a << ", " << "b=" << b;
  6. if (0 < a && a < b) {
  7. cout << " => " << (a * a + b * b) / (2 * a) << endl;
  8. } else {
  9. cout << " => error." << endl;
  10. }
  11. }
  12. }
  13.  
Success #stdin #stdout 0s 15240KB
stdin
1 2
2 4
stdout
a=1, b=2 => 2.5
a=2, b=4 => 5