Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   removing a number from an arry (http://www.go4expert.com/forums/removing-arry-t18339/)

cpulocksmith 3Jul2009 22:19

removing a number from an arry
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.


    //local variables
    int statas;
    int rolled[5];
    char reroll;
    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... ";

            if (reroll == 'y'){

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

int x=0;
for (x = 0; x <= 5; x++)

cout<<"str... ";

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?

xpi0t0s 4Jul2009 03:41

Re: removing a number from an arry
how about something like

if (x!=entered_num)

in the for loop.

All times are GMT +5.5. The time now is 15:59.