Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int main()
- {
- int n;
- cin >> n;
- double maleCounter = 0;
- double totalMaleHeight = 0;
- double avarageMaleHeight = 0;
- double femaleCounter = 0;
- double totalFemaleHeight = 0;
- double avarageFemaleHeight = 0;
- for (int i = 0; i < n; i++) {
- double readNumber;
- cin >> readNumber;
- if (readNumber < 0) {
- totalMaleHeight = totalMaleHeight + readNumber;
- maleCounter++;
- }
- if (readNumber >= 0) {
- totalFemaleHeight = totalFemaleHeight + readNumber;
- femaleCounter++;
- }
- }
- avarageMaleHeight = totalMaleHeight / maleCounter;
- avarageFemaleHeight = totalFemaleHeight / femaleCounter;
- cout << "vidvaikinu = "+ to_string(avarageMaleHeight * -1) + ", vidmerginu = " + to_string(avarageFemaleHeight) << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement