First off, I have searched the forums and have not stumbled across the answer to my question. If I overlooked it feel free not to post here or close the thread or link me to the correct thread. I apologize if i missed it.
I'm trying to create a number gen for a...draw the name out of the hat kinda thing. So I want each number to be used only once. I've searched all over the net and the best solution I've found so far is to try and put each value into an array then have it check to see if the number is used yet and then not use it if found. But the source code wasn't listed for that he just kinda explained it and not being in C++ for too long I don't quite understand. If you know of a better way please explain it.
This is my code at the moment for the entire thing, there are commented out attempts within it:
#include <cstdlib>
#include <iostream>
#include <ctime>
using namespace std;
int quant;
char answer;
int change;
int output ;
char choice;
//int once[];
/*int checkNum()
{
if (once[quant]) ==
}//checkNum*/
int randomize()
{
int x;
int y = 1;
int arr[quant];
while (x != quant)
{
// while(output != arr[1 % y])// % arr[y])
// {
cout << (output = ((rand() % quant)+1)), "\n";
// }
output != arr[(y^0) % y];
arr[y] = output;
quant--;
//x++;
y++;
}//while
cin.get();
}//randomize
int main()
{
srand( time(NULL));//Different values for random.
cout << "How many people to choose from?\n";
cin >> quant;
cout << quant << " people, this is correct? y/n\n";
cin >> answer;
cin.ignore();
if ( answer == 'y' )
{
cout << "Ok, assign each person a number and I will randomize them.\n";
cout << "Press ENTER to list numbers";
cin.get();
randomize();
while (choice != 'n')
{
cout << "Would you like to try again? y/n \n";
cin >> choice;
if (choice == 'y')
{
main();
}
if (choice == 'n')
{
return 0;
}
else
{
cout << "Sorry, I didn't catch that.";
}//else
}//while
}//if
if ( answer == 'n' )
{
main();
}//if
if (answer != ('n')||('y'))
{
cout << "Error";
cin.get();
main();
}//else
return 0;
}//main