Fixed.
Printable View
Fixed.
You are using the nested loops of the form:Quote:
Originally posted by Qui
Hi, I am having a little trouble with my sorting algorithm, it just stops after the first pass of the internal loop :confused:, could someone please look over this and tell me what I am doing wrong.
Thanks Qui.
Code:void sort(Holiday *pHoliday)
{
for(pHoliday = Head; pHoliday != NULL; pHoliday = pHoliday->next)
{
for(pHoliday = Head; pHoliday != NULL; pHoliday = pHoliday->next)
{
if(pHoliday->price > pHoliday->next->price)
insert(pHoliday->next,pHoliday);
}
}
}
You just overwrote the outer loop value with the inner loop value. Change one of them to another variable nameCode:for (i=0; i<lim; i++)
for (i=0; i<lim; i++)
Hi, yes I can see what you mean, unfortunately it doesnt make a difference I had it that way before and it didnt work so I tried it this way and it still doenst work.:D , there must be something.
Fixed