removing a number from an arry

cpulocksmith's Avatar, Join Date: Jul 2008
Skilled contributor
ok, i need some help on a problem i am having. i think this should be an easy one for you guys to figure out but my feeble brain cannot come up with it and anything i found using google has failed me so here it is.
i want to out put an arry on numbers then have you select one. one that number is selected i want the program to loop and out put the same batch of numbers, but i want it to leave out the number that was selected. here is what i have.

Code:
    
    //local variables
    int statas;
    int rolled[5];
    char reroll;
    system("cls");
    
       
    rolled[0] = (rand()%16)+3;
    rolled[1] = (rand()%16)+3;
    rolled[2] = (rand()%16)+3;
    rolled[3] = (rand()%16)+3;
    rolled[4] = (rand()%16)+3;
    rolled[5] = (rand()%16)+3;
     
cout<<"the numbers that will be used for your stats will now be generated \n \n";
cout<<"1)... "<< rolled[0]<<endl;
cout<<"2)... "<< rolled[1]<<endl;
cout<<"3)... "<< rolled[2]<<endl;
cout<<"4)... "<< rolled[3]<<endl;
cout<<"5)... "<< rolled[4]<<endl;
cout<<"6)... "<< rolled[5]<<endl;

cout<<"\n reroll? y/n... ";
cin>>reroll;
cin.ignore();

            if (reroll == 'y'){
                       gen();
                       }
            else{
         
         system("cls");
}

cout<<"now to place them in the stat you disire\n"<<endl;

int x=0;
for (x = 0; x <= 5; x++)
cout<<rolled[x]<<endl;

cout<<"str... ";
              cin>>statas;

so yeah... i want to enter say number 3. so click, i entered 3. i want the third number removed from the "rolled array" so that it will not be repeated the next time around. so any ideas?
0
xpi0t0s's Avatar, Join Date: Aug 2004
Mentor
how about something like
Code:
if (x!=entered_num)
  cout<<rolled[x]<<endl;
in the for loop.