#include #include #include void compact (apvector &list,int &N); void main (void) { ifstream infile ("numbers.txt",ios::in); apvector list(0); int x,n = 0; while (infile >> x) { list.resize(list.length()+1); list[list.length()-1] = x; n++; } cout << "Before : \n" << list[0]; for (int y = 1;y < list.length();y++) { cout << "," << list[y]; } compact (list,n); cout << "\n\nAfter : \n" << list[0]; for (y = 1;y < list.length();y++) { cout << "," << list[y]; } cout << "\n\n"; } void compact (apvector &list,int &n) { int diff = 0; for (int y = 0;y < list.length();y++) { list[y - diff] = list[y]; if (list[y] == 0) diff++; } list.resize(list.length() - diff); }