#include <iostream>
#include <cmath>
signed main()
{
setlocale(LC_ALL, "Rus");
int cnt, countBoys = 0, countGirls = 0, sumHeightBoys = 0, sumHeightGirls = 0;
std::cout << "Введите количество детей в классе: ";
std::cin >> cnt;
int* height = new int[cnt];
for (int i = 0; i < cnt; i++)
std::cout << "Рост ребёнка №" << i + 1 << ": ";
std::cin >> height[i];
if (height[i] < 0) {
countBoys++;
sumHeightBoys += height[i];
}
else {
countGirls++;
sumHeightGirls += height[i];
std::cout << "Средний рост мальчиков: " << abs(sumHeightBoys) / countBoys << std::endl;
std::cout << "Средний рост девочек: " << sumHeightGirls / countGirls << std::endl;
return 0;
#include <iostream>
#include <cmath>
signed main()
{
setlocale(LC_ALL, "Rus");
int cnt, countBoys = 0, countGirls = 0, sumHeightBoys = 0, sumHeightGirls = 0;
std::cout << "Введите количество детей в классе: ";
std::cin >> cnt;
int* height = new int[cnt];
for (int i = 0; i < cnt; i++)
{
std::cout << "Рост ребёнка №" << i + 1 << ": ";
std::cin >> height[i];
if (height[i] < 0) {
countBoys++;
sumHeightBoys += height[i];
}
else {
countGirls++;
sumHeightGirls += height[i];
}
}
std::cout << "Средний рост мальчиков: " << abs(sumHeightBoys) / countBoys << std::endl;
std::cout << "Средний рост девочек: " << sumHeightGirls / countGirls << std::endl;
return 0;
}