This seems to be a common problem where the check50 program indicates a problem with the sort_pairs function. Here was my implementation of that function:
int w;
int l;
int w1;
int l1;
for (int i=0; i < pair_count; i++)
{
for (int j=0; j < pair_count; j++)
{
w = pairs[i].winner;
l = pairs[i].loser;
w1 = pairs[j].winner;
l1 = pairs[j].loser;
if (preferences[w][l] < preferences[w1][l1])
{
pairs[j].winner = w;
pairs[j].loser = l;
pairs[i].winner = w1;
pairs[i].loser = l1;
}
}
}
return;
I've gone over the logic multiple times and it seems sound but check50 disagrees. Any ideas?