Sachees

srednia harmoniczna

Aug 27th, 2016
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #include <iostream>
  2.  
  3.  
  4. double harmonicAverage(double, double);
  5.  
  6.  
  7. int main()
  8. {
  9. double First, Second;
  10. for(;;)
  11. {
  12. std::cout << "Podaj dwie liczby, 0 zeby skonczyc.\n";
  13. std::cin >> First >> Second;
  14. if(First == 0 || Second == 0)
  15. break;
  16. std::cout << "Srednia harmoniczna tych liczb to " << harmonicAverage(First, Second) << ". \n";
  17. }
  18. std::cout << "Wpisano 0 lub litere, koniec programu. ";
  19. return 0;
  20. }
  21.  
  22. double harmonicAverage(double x, double y)
  23. {
  24. double result = (2.0*x*y)/(x + y);
  25. return result;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment