I'm green on all the criteria before sort_pair. Here's my code so far:
// Sort pairs in decreasing order by strength of victory
void sort_pairs(void)
{
// TODO
// Create array of strengths of victory
int strengths[pair_count];
for (int i = 0; i < pair_count; i++)
{
strengths[i] = preferences[pairs[i].winner][pairs[i].loser];
}
// Bubble sort
int swaps = 1;
while (swaps > 0)
{
swaps = 1;
for (int i = 0; i < pair_count - 1; i++)
{
if (strengths[i] < strengths[i + 1])
{
pair temp = pairs[i];
pairs[i] = pairs[i + 1];
pairs[i + 1] = temp;
swaps++;
}
}
swaps = swaps - 1;
}
}
The code compiles but it doesn't pass check50. I'm not sure what's wrong with this. Could I please get some advice?