Page 372, Exercise 2
The call is:
table(list,n);
void table(element list [], int n)
{/*modified table to rearrange results of distribution counting*/
int i, k;
element temp;
for (i = 0; i < n; i++)
if (list[i].count != i)
/*if records are out of order swap until they're in place
very simple exchange version*/
do {
k=list[i].count;
temp=list[k];
list[k]=list[i];
list[i]=temp;
}while (list[i].count != i);
}
|