MaxMin
C
#include <stdio.h>
void splitArray(int arr[], int max[], int min[], int length) {
for (int i = 0; i < length; i = i + 2){
if (arr[i] >= arr[i+1]){
max[cnt] = arr[i];
min[cnt] = arr[i+1];
}
else {
min[cnt] = arr[i];
max[cnt] = arr[i+1];
}
cnt++
}
}
void maxSort(int arr[]) {
}
void minSort(int arr[]) {
}
int main() {
int num ; scanf("%d", &num);
int arr[50], max, min;
for (int i = 0; i < num; i++) scanf("%d",&arr[i]);
if (num == 1) printf("%d",(arr[0]*arr[0]));
else {
max = arr[0];
min = arr[num-1];
for (int i = 0;i < num;i++) {
if (max < arr[i]) max = arr[i];
if (min > arr[i]) min = arr[i];
}
printf("%d",(max*min));
}
}
Output
Embed on website
To embed this program on your website, copy the following code and paste it into your website's HTML:
Comments
This comment belongs to a banned user and is only visible to admins.
This comment belongs to a deleted user and is only visible to admins.