#include <iostream>
#include <limits>
#include <string>
using namespace std;
string f(int arr[], int size) {
if (size <= 0) {
return "Array is empty.";
}
int minIndex = 0;
int minValue = arr[0];
for (int i = 1; i < size; i++) {
if (arr[i] < minValue) {
minValue = arr[i];
minIndex = i;
}
}
if (minIndex < size / 2) {
return "The minimum element is in the first half.";
} else {
return "The minimum element is in the second half.";
}
}
int main() {
const int N = 10;
int arr[N];
cout << "Enter " << N << " integers:" << endl;
for (int i = 0; i < N; i++) {
cin >> arr[i];
}
string result = f(arr, N);
cout << result << endl;
return 0;
}
#include <iostream>
using namespace std;
string f(int a[], int n) {
if (n <= 0) return "Array is empty.";
int minI = 0, minV = a[0];
for (int i = 1; i < n; i++) if (a[i] < minV) minV = a[i], minI = i;
return minI < n / 2 ? "The minimum element is in the first half." : "The minimum element is in the second half.";
}
int main() {
int a[10];
cout << "Enter 10 integers:" << endl;
for (int &x : a) cin >> x;
cout << f(a, 10) << endl;
return 0;
}
#include <limits>
#include <string>
using namespace std;
string f(int arr[], int size)
if (size <= 0);
return "Array is empty.";
int minIndex = 0;
int minValue = arr[0];
for (int i = 1; i < size; i++)
if (arr[i] < minValue)
minValue = arr[i];
minIndex = i;
if (minIndex < size / 2)
return "The minimum element is in the first half.";
else
return "The minimum element is in the second half.";
int main()
const int N = 10;
int arr[N];
cout << "Enter " << N << " integers:" << endl;
for (int i = 0; i < N; i++)
cin >> arr[i];
string result = f(arr, N);
cout << result << endl;
return 0;