Is there any way for b to change pozition ?

Is there any way for b to change pozition ?

Is there way for ID to change with Finish ?

like

finis ID
8 2
7 7
6 8
5 6
4 3
3 4
2 5
1 1



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
int main()
{

  int Finis[8] = {1, 8, 4, 3, 2, 5, 7, 6};
  int  ID[8] =   {1, 2, 3, 4, 5, 6, 7, 8};

   int x =0;

 for (int i = 0; i < 8; i++)
 {
     int mim = i;
     for (int j = i+1; j < 8; j++)
     {
         if (Finis[j] > Finis[mim])
         {
             mim = j;
         }
     }
     int aux = Finis[mim];
     Finis[mim] = Finis[i];
     Finis[i] = aux;
     cout << Finis[i] << endl;
 }


return 0;
}
There are two arrays, what you do to one, you must also do to the other
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
    for (int i = 0; i < 8; i++)
    {
        int mim = i;
        for (int j = i+1; j < 8; j++)
        {
            if (Finis[j] > Finis[mim])
            {
                mim = j;
            }
        }
        int aux    = Finis[mim];
        Finis[mim] = Finis[i];
        Finis[i]   = aux;

        aux        = ID[mim];
        ID[mim]    = ID[i];
        ID[i]      = aux;
    }


Then just add a simple loop to print out both arrays Finis and ID.
Topic archived. No new replies allowed.