Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- #define size 10
- int min_index(double *array)
- {
- double min = array[0];
- int index = 0;
- for(int i = 0 ; i != size ; ++i)
- {
- if(array[i]<min)
- {
- min = array[i];
- index = i;
- }
- }
- return index;
- }
- void print_array(double * array)
- {
- for(int i = 0 ; i != size ; ++i)
- {
- printf("%lf ",array[i]);
- }
- printf("\n");
- }
- int main()
- {
- double array[size];
- double yArray[size];
- for(int i = 0 ; i != size ; ++i)
- {
- array[i] = sin((double)i)/(2*exp(4));
- }
- print_array(array);
- double min = array[min_index(array)];
- for(int i = 0 ; i != size ; ++i)
- {
- yArray[i] = array[i]-min;
- }
- print_array(yArray);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement