Limiting choices.

Hi,
I have code that asks the user to choose from a list of numbers, but they can only choose one number once. Occasionally a number will repeat in the list, so i cant just not let them choose 12 if they chose a 12 before, because there could be a 2nd 12. My code is this so far:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
int statgen();
int choosestat(int st1, int st2, int st3, int st4, int st5, int st6);
void ClearScreen();
 
int main()
{
	srand((unsigned)time(0)); 
	int st1, st2, st3, st4, st5, st6;
	int str, con, dex, inl, wis, cha;
	st1 = statgen();
	st2 = statgen();
	st3 = statgen();
	st4 = statgen();
	st5 = statgen();
	st6 = statgen();
	std::cout << "Your first  is " << st1 << "\n";
	std::cout << "Your second stat is " << st2 << "\n";
	std::cout << "Your third stat is " << st3 << "\n";
	std::cout << "Your fourth stat is " << st4 << "\n";
	std::cout << "Your fifth stat is " << st5 << "\n";
	std::cout << "Your sixth stat is " << st6 << "\n";
	
	ClearScreen();
	
		std::cout << "Which of the following would you like to be STR:\n";
	str = choosestat(st1, st2, st3, st4, st5, st6);
	std::cout << "STR=" << str << "\n";
	
	ClearScreen();
	
		std::cout << "Which of the following would you like to be CON:\n";
	con = choosestat(st1, st2, st3, st4, st5, st6);
	std::cout << "CON=" << con << "\n";
	
	ClearScreen();
	
		std::cout << "Which of the following would you like to be DEX:\n";
	dex = choosestat(st1, st2, st3, st4, st5, st6);
	std::cout << "DEX=" << dex << "\n";
	
	ClearScreen();
	
		std::cout << "Which of the following would you like to be INT:\n";
	inl = choosestat(st1, st2, st3, st4, st5, st6);
	std::cout << "INT=" << inl << "\n";
	
	ClearScreen();
	
		std::cout << "Which of the following would you like to be WIS:\n";
	wis = choosestat(st1, st2, st3, st4, st5, st6);
	std::cout << "WIS=" << wis << "\n";
	
	ClearScreen();
	
		std::cout << "Which of the following would you like to be CHA:\n";
	cha = choosestat(st1, st2, st3, st4, st5, st6);
	std::cout << "CHA=" << cha << "\n";
	
	
	return 0;
}
	
int statgen()
{
	// defining my variables and giving my random a seed 
	int d1, d2, d3, d4, sum;
	d1 = rand() % 6+1;
	d2 = rand() % 6+1;
	d3 = rand() % 6+1;
	d4 = rand() % 6+1;
	

	// sets the lowest number to 0 so that the stat isnt above 18
	if (d1<=d2 && d1<=d3 && d1<=d4)
		d1 = 0;
	if (d2<=d1 && d2<=d3 && d2<=d4)
		d2 = 0;
	if (d3<=d1 && d3<=d2 && d3<=d4)
		d3 = 0;
	if (d4<=d1 && d4<=d2 && d4<=d3)
		d4 = 0;
	
	//sets the sum equal to all the dice including the 0
	sum = d1+d2+d3+d4;

	return sum;	
	}
	
int choosestat(int st1, int st2, int st3, int st4, int st5, int st6)
{
	int choice;
	
	while (choice != st1 && choice != st2 && choice != st3 && choice != st4 && choice != st5 && choice != st6)
	{
		std::cout << "Please choose one of the stats provided\n";
		std::cout << st1 << "\n";
		std::cout << st2 << "\n";
		std::cout << st3 << "\n";
		std::cout << st4 << "\n";
		std::cout << st5 << "\n";
		std::cout << st6 << "\n";
		std::cin >> choice;
		
		}
			
	
	return choice;
}
Store the user input somewhere and then check if the user has already given the same input.
Topic archived. No new replies allowed.