» 
c++ help....
Help...I need my sleep.
I have to write a c++ program that will take an array and i should be able to add or remove elements from the array..this is what i have.
#include <iomanip>
#include <iostream>
using namespace std;
void removeIt (int array[],int removePos,int arrayLength)
{
int x,number,count=0,space_filler=20;
system("cls");
cout <<setw(45) <<"Array Contents";
x=arrayLength;
for (number=0; number<=x; number++)
{
x--;
if (removePos-1==array[number])
{
do
{
arrayLength--;
}while(x>=0);
}
cout<<array[3];
}
}
int main()
{
int space_filler=20,number,count=0,removePos;
int array[20]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18};
char nextStep;
cout <<setw(45) <<"Array Contents";
for (number=0;number<=17;number++)
{
count++;
cout <<"\n" <<setw(37) <<count <<" " <<array[number];
space_filler--;
}
while (space_filler>=0)
{
cout<<"\n";
space_filler--;
}
cout <<"What would you like to do next? Choose from (R)emove, "
<<"(I)nsert, or (E)nd. ";
cin >>nextStep;
if (nextStep == 'R')
{
cout<<"What position do you want to remove? ";
cin>>removePos;
removeIt(array,removePos,count);
}
return 0;
}
Can some one please show me how to do this over and over again with the screen showing only the number that are still left in the array?
|