Advertisement
daniv1

29.11

Oct 29th, 2018
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.52 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. int min_index(double *array, int size)
  5. {
  6.     double min = array[0];
  7.     int index = 0;
  8.     for(int i = 0 ; i != size ; ++i)
  9.     {
  10.         if(array[i]<min)
  11.         {
  12.             min = array[i];
  13.             index = i;
  14.         }
  15.     }
  16.     return index;
  17. }
  18.  
  19. int main()
  20. {
  21.     double array[14]= {0.1,-25.2,0,888.35,
  22.                        -424.48,0,15,-7,-195,2,
  23.                        0,0.04,-15.2,57.6};
  24.     int n = 14;
  25.     printf("min index  = %d\n",min_index(array,n));
  26.  
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement