Fixed.
Fixed.
Last edited by Qui; 03-11-2004 at 03:59 PM.
You are using the nested loops of the form: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 , 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++)
Definition: Politics -- Latin, from
poly meaning many and
tics meaning blood sucking parasites
-- Tom Smothers
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. , there must be something.
Fixed
Last edited by Qui; 03-11-2004 at 03:59 PM.