void Compact(apvector<int> &List, int &N)
//Pre:List contains integers from 0...N-1
//PostCondition all 0's have been removed from the list; N is reduced as appropriate
{
for(int i = 0; N > i; i++)
{
while(List[i] == 0)
{
for(int c = 0; c < N; c++)
{
List[i] = List[i+1];
N--;
}
}
}
List.resize(N);
for(int b = 0; b != List.length(); b++)
{
cout << List[b] << " ";
}
}
and now I am in an endless loop...I am trying to make it so it reads the numbers off an array and removes all the zero and then put everything back into an array of vectors. and then resizes it to save memory...also a parameter is not to use a second array. I don't know whats wrong...this should work but it doesn't someone help me....also I am a high school student...also I am using very basic class's such as iostream, iomanip, apvector, math, fstream, limits and apstring. Also I am using MSVC 6(the latest one) if that helps