Ответ:
#include <iostream>
using namespace std;
int main()
{
int playerHeights[9] = { 160, 175, 166, 188, 176, 171, 181, 190, 169 };
int sum = 0;
int numPlayers = 9;
// Calculate sum of player heights
for (int i = 0; i < numPlayers; i++)
sum += playerHeights[i];
}
// Calculate average height
double averageHeight = (double)sum / numPlayers;
cout << "Average height: " << averageHeight << " centimeters\n" << endl;
// Print players of average height
cout << "Players of average height:" << endl;
if (playerHeights[i] >= averageHeight - 1 && playerHeights[i] <= averageHeight + 1)
cout << "Player " << i + 1 << ": " << playerHeights[i] << " inches" << endl;
return 0;
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Ответ:
#include <iostream>
using namespace std;
int main()
{
int playerHeights[9] = { 160, 175, 166, 188, 176, 171, 181, 190, 169 };
int sum = 0;
int numPlayers = 9;
// Calculate sum of player heights
for (int i = 0; i < numPlayers; i++)
{
sum += playerHeights[i];
}
// Calculate average height
double averageHeight = (double)sum / numPlayers;
cout << "Average height: " << averageHeight << " centimeters\n" << endl;
// Print players of average height
cout << "Players of average height:" << endl;
for (int i = 0; i < numPlayers; i++)
{
if (playerHeights[i] >= averageHeight - 1 && playerHeights[i] <= averageHeight + 1)
{
cout << "Player " << i + 1 << ": " << playerHeights[i] << " inches" << endl;
}
}
return 0;
}