On Sat, 4 Oct 1997, Brian Williams - Nashak wrote: > On Sat, 4 Oct 1997, Andrew Helm wrote: > > SNIP > > Okay, what I mean is.. I have an array in the pfile.. int memorized[100]; > which stores spellnums, if they forget a spell, I want it to set the > spellnum to 0, and if there is a 0 in the array, I want it to move all > entries to the left one after the zero, so there are no more zeros until > the end of the array > i.e. > 1, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 5 > would equal this: > 1, 2, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 Mailer code (Do not consider sorted array): #define MAX_ARRAY 100 /* Number of elements in the array */ int x, y; for(x=0, y=MAX_ARRAY-1; x < y; ) { if (array[x]!=0) { x++; continue; } if (array[x]==0 && array[y]==0) { y--; continue; } array[x++] = array[y]; array[y--] = 0; } Hope it gives an idea. Erik Niese-Petersen AKA Quint the Typo Dane StrangeMUD coder: strangemud.org 9332 +------------------------------------------------------------+ | Ensure that you have read the CircleMUD Mailing List FAQ: | | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html | +------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/08/00 PST