Sachees

wyniki golfowe

Aug 27th, 2016
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. const int ArSize = 10;
  4.  
  5. int enterResults(double [], const int);
  6. void showResults(double [], int);
  7. double averageScore(double [], int);
  8.  
  9. int main()
  10. {
  11. double golfresults[ArSize];
  12. std::cout << "Podawaj do max. 10 liczb, wpisz inny znak niz cyfra aby zakonczyc.\n";
  13. int count = enterResults(golfresults, ArSize);
  14. std::cout << "Oto twoje liczby:\n";
  15. showResults(golfresults, count);
  16. std::cout << "A oto ich srednia: " << averageScore(golfresults, count) << ".\n";
  17. return 0;
  18. }
  19.  
  20. int enterResults(double results[], const int Size)
  21. {
  22. int i;
  23. for(i = 0; i < Size; i++)
  24. {
  25. std::cin >> results[i];
  26. if(!std::cin)
  27. break;
  28. }
  29. return i;
  30. }
  31.  
  32. void showResults(double results[], int Size)
  33. {
  34. for(int i = 0; i < Size; i++)
  35. {
  36. std::cout << results[i] <<", ";
  37. }
  38. std::cout << "\n";
  39. }
  40. double averageScore(double results[], int Size)
  41. {
  42. double total = 0;
  43. for(int i = 0; i < Size; i++)
  44. total += results[i];
  45. return total/Size;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment