Advertisement
daniv1

29.12

Oct 29th, 2018
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.80 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. #define size 10
  5. int min_index(double *array)
  6. {
  7.     double min = array[0];
  8.     int index = 0;
  9.     for(int i = 0 ; i != size ; ++i)
  10.     {
  11.         if(array[i]<min)
  12.         {
  13.             min = array[i];
  14.             index = i;
  15.         }
  16.     }
  17.     return index;
  18. }
  19. void print_array(double * array)
  20. {
  21.     for(int i = 0 ; i != size ; ++i)
  22.     {
  23.         printf("%lf ",array[i]);
  24.     }
  25.     printf("\n");
  26. }
  27.  
  28.  
  29. int main()
  30. {
  31.  
  32.     double array[size];
  33.     double yArray[size];
  34.     for(int i = 0 ; i != size ; ++i)
  35.     {
  36.         array[i] = sin((double)i)/(2*exp(4));
  37.     }
  38.  
  39.     print_array(array);
  40.  
  41.     double min = array[min_index(array)];
  42.  
  43.     for(int i = 0 ; i != size ; ++i)
  44.     {
  45.         yArray[i] = array[i]-min;
  46.     }
  47.     print_array(yArray);
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement