using namespace std;
int findMax(int arr[], int n) {
int max_val = arr[0]; // max_val o'zgaruvchini arr[0] qiymatiga tenglaymiz
for(int i=1; iif(arr[i] > max_val) {
max_val = arr[i]; // agar arr[i] max_val ni oshib turing, unda max_val ni arr[i] qiymatiga tenglaysiz
}
}
return max_val;
}
int findMin(int arr[], int n) {
int min_val = arr[0]; // min_val o'zgaruvchini arr[0] qiymatiga tenglaymiz
for(int i=1; iif(arr[i] < min_val) {
min_val = arr[i]; // agar arr[i] min_val dan kichik bolsa, unda min_val ni arr[i] qiymatiga tenglaysiz
}
}
return min_val;
}
int main() {
int n;
cout << "N ni kiriting: ";
cin >> n;
int arr[n]; // n ta elementdan iborat massiv
cout << "Massivni kiriting: ";
for(int i=0; icin >> arr[i];
}
int max_val = findMax(arr, n); // Massivning eng katta elementini topish
int min_val = findMin(arr, n); // Massivning eng kichik elementini topish
float avg_val = (max_val+min_val)/2.0; // max va min lari o‘rtasidagi sonni hisoblash
// Massivni chiqaramiz
cout << "Massiv: ";
for(int i=0; icout << arr[i] << " ";
}
// Javobni chiqaramiz
cout << "\nMaximum qiymati: " << max_val << endl;
cout << "Minimum qiymati: " << min_val << endl;
cout << "Ortasidagi qiymat: " << avg_val << endl;
return 0;
}