»
 

Go Back   ResellerRatings Store Ratings > ResellerRatings Forums > Tech Support

Reply
 
LinkBack Thread Tools Display Modes
Old 02-03-2004, 12:02 PM   #1 (permalink)
Registered User
 
Join Date: Nov 2002
Posts: 52
beerGod is on a distinguished road
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?

beerGod is offline   Reply With Quote
Reply




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Most Active Discussions

Recent Discussions

All times are GMT -6. The time now is 10:38 AM.