#include <iostream>
using namespace std;
int main()
{
cout << "Измерение ростов всех студентов\n";
srand(time(0));
int a[16], b[16];
for(int i = 1; i < 16; i++)
a[i]=rand()%50+140;
cout << "a[" << i << "] = " << a[i] << "; ";
}
cout << "\nРост самого высокого студента (номер): ";
int max = 0, min = 65535, k = 0, sum = 0, j1, j2;
if(a[i] > max)
max = a[i];
j1 = i;
if(a[i] < min)
min = a[i];
j2 = i;
sum += a[i];
if(a[i] > 170)
k++;
b[k] = a[i];
cout << j1 << endl;
cout << "Рост самого низкого студента (номер): " << j2 << endl;
cout << "Средний рост " << sum / 15.0 << endl;
cout << "Массив b: ";
for(int i = 1; i <= k; i++)
cout << "b[" << i << "] = " << b[i] << "; ";
cout << endl;
return 0;
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
#include <iostream>
using namespace std;
int main()
{
cout << "Измерение ростов всех студентов\n";
srand(time(0));
int a[16], b[16];
for(int i = 1; i < 16; i++)
{
a[i]=rand()%50+140;
cout << "a[" << i << "] = " << a[i] << "; ";
}
cout << "\nРост самого высокого студента (номер): ";
int max = 0, min = 65535, k = 0, sum = 0, j1, j2;
for(int i = 1; i < 16; i++)
{
if(a[i] > max)
{
max = a[i];
j1 = i;
}
if(a[i] < min)
{
min = a[i];
j2 = i;
}
sum += a[i];
if(a[i] > 170)
{
k++;
b[k] = a[i];
}
}
cout << j1 << endl;
cout << "Рост самого низкого студента (номер): " << j2 << endl;
cout << "Средний рост " << sum / 15.0 << endl;
cout << "Массив b: ";
for(int i = 1; i <= k; i++)
cout << "b[" << i << "] = " << b[i] << "; ";
cout << endl;
return 0;
}