Posts: 206
Threads: 31
Joined: Feb 2008
Reputation:
0
Hello!
So, I have this system, where it generates random questions.
There is one problem - how could I generate a question, that hasn't been given yet?
For example, I have pvars: t_que[1-5];
and they store the questions they already been given, and I also have the maximum number of questions that exists (15), so how could i select a random value from 15, that isn't t_que[1-5] pvars?
Posts: 1,506
Threads: 69
Joined: Feb 2008
Just made this;
pawn Код:
RandomValue()
{
new value = random(15);
if(value >= 1 && value <= 5 || value == 0){ return RandomValue(); }
return value;
}
pawn Код:
// USAGE
printf("%d",RandomValue());
integer = RandomValue();
Tested it here (223 times or somethin);
Код:
[14:50:03] 9
[14:50:03] 11
[14:50:03] 14
[14:50:03] 8
[14:50:03] 6
[14:50:03] 10
[14:50:03] 7
[14:50:03] 6
[14:50:03] 9
[14:50:03] 7
[14:50:03] 10
[14:50:03] 11
[14:50:03] 7
[14:50:03] 14
[14:50:03] 8
[14:50:03] 11
[14:50:03] 7
[14:50:03] 7
[14:50:03] 14
[14:50:03] 6
[14:50:03] 12
[14:50:03] 14
[14:50:03] 14
[14:50:03] 11
[14:50:03] 7
[14:50:03] 13
[14:50:03] 8
[14:50:03] 7
[14:50:03] 9
[14:50:03] 13
[14:50:03] 11
[14:50:03] 14
[14:50:03] 7
[14:50:03] 8
[14:50:03] 12
[14:50:03] 13
[14:50:03] 9
[14:50:03] 9
[14:50:03] 10
[14:50:03] 7
[14:50:03] 10
[14:50:03] 12
[14:50:03] 13
[14:50:03] 11
[14:50:03] 9
[14:50:03] 10
[14:50:03] 10
[14:50:03] 11
[14:50:03] 13
[14:50:03] 9
[14:50:03] 9
[14:50:03] 13
[14:50:03] 10
[14:50:03] 10
[14:50:03] 9
[14:50:03] 14
[14:50:03] 7
[14:50:03] 14
[14:50:03] 13
[14:50:03] 14
[14:50:03] 7
[14:50:03] 8
[14:50:03] 7
[14:50:03] 9
[14:50:03] 8
[14:50:03] 14
[14:50:03] 11
[14:50:03] 13
[14:50:03] 9
[14:50:03] 9
[14:50:03] 11
[14:50:03] 14
[14:50:03] 11
[14:50:03] 9
[14:50:03] 13
[14:50:03] 6
[14:50:03] 6
[14:50:03] 10
[14:50:03] 14
[14:50:03] 13
[14:50:03] 8
[14:50:03] 7
[14:50:03] 12
[14:50:03] 13
[14:50:03] 12
[14:50:03] 13
[14:50:03] 9
[14:50:03] 6
[14:50:03] 9
[14:50:03] 14
[14:50:03] 8
[14:50:03] 8
[14:50:03] 14
[14:50:03] 8
[14:50:03] 13
[14:50:03] 11
[14:50:03] 9
[14:50:03] 13
[14:50:03] 14
[14:50:03] 9
[14:50:03] 10
[14:50:03] 10
[14:50:03] 11
[14:50:03] 14
[14:50:03] 11
[14:50:03] 10
[14:50:03] 10
[14:50:03] 13
[14:50:03] 11
[14:50:03] 10
[14:50:03] 13
[14:50:03] 6
[14:50:03] 11
[14:50:03] 14
[14:50:03] 10
[14:50:03] 6
[14:50:03] 11
[14:50:03] 8
[14:50:03] 10
[14:50:03] 9
[14:50:03] 11
[14:50:03] 13
[14:50:03] 13
[14:50:03] 12
[14:50:03] 9
[14:50:03] 13
[14:50:03] 10
[14:50:03] 12
[14:50:03] 9
[14:50:03] 13
[14:50:03] 11
[14:50:03] 12
[14:50:03] 12
[14:50:03] 9
[14:50:03] 9
[14:50:03] 12
[14:50:03] 9
[14:50:03] 13
[14:50:03] 6
[14:50:03] 6
[14:50:03] 13
[14:50:03] 8
[14:50:03] 13
[14:50:03] 8
[14:50:03] 9
[14:50:03] 8
[14:50:03] 13
[14:50:03] 6
[14:50:03] 9
[14:50:03] 8
[14:50:03] 14
[14:50:03] 7
[14:50:03] 8
[14:50:03] 12
[14:50:03] 8
[14:50:03] 7
[14:50:03] 10
[14:50:03] 9
[14:50:03] 11
[14:50:03] 13
[14:50:03] 6
[14:50:03] 7
[14:50:03] 10
[14:50:03] 9
[14:50:03] 13
[14:50:03] 10
[14:50:03] 13
[14:50:03] 11
[14:50:03] 10
[14:50:03] 10
[14:50:03] 14
[14:50:03] 12
[14:50:03] 12
[14:50:03] 8
[14:50:03] 6
[14:50:03] 9
[14:50:03] 14
[14:50:03] 13
[14:50:03] 14
[14:50:03] 7
[14:50:03] 7
[14:50:03] 14
[14:50:03] 9
[14:50:03] 14
[14:50:03] 7
[14:50:03] 7
[14:50:03] 7
[14:50:03] 10
[14:50:03] 14
[14:50:03] 9
[14:50:03] 7
[14:50:03] 7
[14:50:03] 12
[14:50:03] 10
[14:50:03] 8
[14:50:03] 7
[14:50:03] 9
[14:50:03] 8
[14:50:03] 10
[14:50:03] 11
[14:50:03] 6
[14:50:03] 12
[14:50:03] 9
[14:50:03] 10
[14:50:03] 6
[14:50:03] 12
[14:50:03] 11
[14:50:03] 11
[14:50:03] 9
[14:50:03] 14
[14:50:03] 12
[14:50:03] 8
[14:50:03] 10
[14:50:03] 8
[14:50:03] 14
[14:50:03] 10
[14:50:03] 12
[14:50:03] 10
[14:50:03] 9
[14:50:03] 6
[14:50:03] 6
[14:50:03] 11
[14:50:03] 6
[14:50:03] 6