Ghislain_Mike

centered array

May 2nd, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.57 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main() {
  4.     int SIZE, MIDDLE, i, MIN, RESULT;
  5.  
  6.     printf("Enter array size: ");
  7.     scanf("%d", &SIZE);
  8.  
  9.     int ARRAY[SIZE];
  10.  
  11.     for(i = 0; i < SIZE; i++) {
  12.         printf("Element %d: ", i + 1);
  13.         scanf("%d", &ARRAY[i]);
  14.     }
  15.  
  16.     MIDDLE = ARRAY[SIZE / 2];
  17.  
  18.     for(i = 0, MIN = ARRAY[0]; i < SIZE; i++) {
  19.  
  20.         if (ARRAY[i] < MIN) {
  21.             MIN = ARRAY[i];
  22.         }
  23.     }
  24.  
  25.     if (MIN == MIDDLE) {
  26.         RESULT = 1;
  27.     } else {
  28.         RESULT = 0;
  29.     }
  30.  
  31.     printf("%d\n", RESULT);
  32.  
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment