Ответ:
см.пояснение
Объяснение:
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
const int n=499;
int main() {
srand(time(0));
int arr[n],min=100,max=-100,iter=0,mediana;
for (int i=0;i<n;i++){
arr[i]=rand()%200-100;
if (min>arr[i])
min=arr[i];
if (max<arr[i])
max=arr[i];
}
if(arr[i]==max)
iter++;
int swap;
for (int i=0;i<n-1;i++){
for (int j=i+1;j<n;j++){
if (arr[i]>arr[j]){
swap=arr[i];
arr[i]=arr[j];
arr[j]=swap;
mediana=n/2+1;
mediana=arr[mediana];
cout<<"min = "<<min<<endl;
cout<<"max = "<<max<<" povtorov: "<<iter<<endl;
cout<<"mediana = "<<mediana;
return 0;
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Ответ:
см.пояснение
Объяснение:
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
const int n=499;
int main() {
srand(time(0));
int arr[n],min=100,max=-100,iter=0,mediana;
for (int i=0;i<n;i++){
arr[i]=rand()%200-100;
if (min>arr[i])
min=arr[i];
if (max<arr[i])
max=arr[i];
}
for (int i=0;i<n;i++){
if(arr[i]==max)
iter++;
}
int swap;
for (int i=0;i<n-1;i++){
for (int j=i+1;j<n;j++){
if (arr[i]>arr[j]){
swap=arr[i];
arr[i]=arr[j];
arr[j]=swap;
}
}
}
mediana=n/2+1;
mediana=arr[mediana];
cout<<"min = "<<min<<endl;
cout<<"max = "<<max<<" povtorov: "<<iter<<endl;
cout<<"mediana = "<<mediana;
return 0;
}