Advertisement
Guest User

Untitled

a guest
Jan 16th, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int n;
  8. cin >> n;
  9. double maleCounter = 0;
  10. double totalMaleHeight = 0;
  11. double avarageMaleHeight = 0;
  12. double femaleCounter = 0;
  13. double totalFemaleHeight = 0;
  14. double avarageFemaleHeight = 0;
  15.  
  16. for (int i = 0; i < n; i++) {
  17. double readNumber;
  18. cin >> readNumber;
  19. if (readNumber < 0) {
  20. totalMaleHeight = totalMaleHeight + readNumber;
  21. maleCounter++;
  22. }
  23. if (readNumber >= 0) {
  24. totalFemaleHeight = totalFemaleHeight + readNumber;
  25. femaleCounter++;
  26. }
  27. }
  28.  
  29. avarageMaleHeight = totalMaleHeight / maleCounter;
  30. avarageFemaleHeight = totalFemaleHeight / femaleCounter;
  31. cout << "vidvaikinu = "+ to_string(avarageMaleHeight * -1) + ", vidmerginu = " + to_string(avarageFemaleHeight) << endl;
  32. system("pause");
  33. return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement