how can I return a number between 2 with a probability of 0,5?
for example I have 3 numbers : 1,2,3 . if i choose 1 my programme has to return 2 or 3. My code works for choice==1 and choice==3 but I dont't know how to do it for choice==2.
Now you have a random result. The second step is to use result with "real numbers". For example:
1 2 3 4 5 6 7 8 9 10 11 12
int fubar( int choice, bool result ) {
switch ( choice ) {
case 1:
return result ? 2 : 3;
case 2:
return result ? 1 : 3;
case 3:
return result ? 1 : 2;
default:
return 0;
}
}