Find second strongest value from array

To add comments, please log in or register
Sinisa Zizic
128
Sinisa Zizic  

     How to find second max/min value from array?  (first down from strongest valute)


     This is my code for max/min values:


           int num_array1[8];

           num_array1[1]=USDstrenght;
           num_array1[2]=EURstrenght;
           num_array1[3]=JPYstrenght;
           num_array1[4]=CADstrenght;      
           num_array1[5]=GBPstrenght;
           num_array1[6]=AUDstrenght;
           num_array1[7]=NZDstrenght;
           num_array1[8]=CHFstrenght;

          int strongvalute=ArrayMaximum(num_array1,WHOLE_ARRAY,0);

          int weakvalute=ArrayMinimum(num_array1,WHOLE_ARRAY,0);

 

      I need:

      int second_strongvalute?

      int second_weakevalute?


Bartlomiej Gorski
10605
Bartlomiej Gorski  
Find max as you did in your example, make a loop on your array, compare values to find largest one, skip index that was found as max.
paul selvan
587
paul selvan  
 ArraySort() will help you to find them 
nicholi shen
2394
nicholi shen  
   int arr[] = {1, 2, 3, 4, 5};
   ArraySort(arr, WHOLE_ARRAY, 0, MODE_DESCEND);
   Print("second highest ", arr[1]);
To add comments, please log in or register