Hi everybody im doing this game project and i got stock in the last part.
so the problem is that is i can make scores to sort from highest to lowest but the name of players will eventually printf in the order it was scanned how can relate this 2 to every player's score print with their own name from highest to lowest
here is my code
Code:
Scores[Counter2]=HIGHSCORE;
TheLastOne[Counter2]=HIGHSCORE;
char Name[20][20];/*names are scanned and store in this array in another part of code*/
for (j=0 ; j<19 ; j++)
{
for (i=0 ; i<19 ; i++)
{
if (Scores[i+1] < Scores[i])
{
t = Scores[i];
Scores[i] = Scores[i + 1];
Scores[i + 1] = t;
}
}
}
system("cls");
for (i=20 ; i>=20-Counter2 ; i--)
{
printf ("%d-%s=>%d\n",21-i,Name[20-i],Scores[i-1]);
}
i tried store the names in another array by comparing them with this code below but didnt work
Code:
for(int k=0;k<20;k++)
{
for(int z=0;z<20;z++)
{
if(TheLastOne[k]==Scores[z])
for(int u=0;u<20;u++)
{
Name2[u][k]=Name[u][19-z];
}
}
}