#include <stdio.h>
#include <stdlib.h>
#include <string.h>
static int a1(int *a)
{
int middleItem;
int midIndex;
if (a == NULL || sizeof(a) % 2 == 0)
return 0;
midIndex = sizeof(a) / 2 ;
middleItem = a[midIndex];
for (int i=0; i<sizeof(a); i++)
{
if (i != midIndex && middleItem >= a[i])
return 0;
}
return 1;
}
int main()
{
int a[] = {9};
for (int i=0; i<sizeof(a); i++)
{
a1(a[i]);
}
return 0;
}
An array with an odd number of elements is said to be centered if all elements (except the middle one) are strictly greater than the value of the middle element. Note that only arrays with an odd number of elements have a middle element.
output:
returns 1 if it is a centered array, otherwise, it returns 0.