The first round of the game seems okay. The game will generate the result but >1 round , the result wont be show.
And the is another mistake I found.
For example, when the random no. is 5134 and my guess is 5143
the game will generate the code O O #, which is wrong, it should be O O # #.
But I cannot find out the reason.
// the for loop is unnecessary around this code, guess it is a relic of other attempt
// assume rightnumber and rightpostion are both 0 each time this code is run
if (input[0] == number[0]){
rightnumber ++;
rightpostion ++;}
if (input[1] == number[1]){
rightnumber ++;
rightpostion ++;}
if (input[2] == number[2]){
rightnumber ++;
rightpostion ++;}
if (input[3] == number[3]){
rightnumber ++;
rightpostion ++;}
// at this point of the code rightnumber == rightpostion
if ((input[0] == number[1]) || (input[0] == number[2]) || (input[0] == number[3]))
rightnumber ++;
elseif ((input[1] == number[0]) || (input[1] == number[2]) || (input[1] == number[3]))
rightnumber ++;
elseif ((input[2] == number[1]) || (input[2] == number[0]) || (input[2] == number[3]))
rightnumber ++;
elseif ((input[3] == number[1]) || (input[3] == number[2]) || (input[3] == number[0]))
rightnumber ++;
// at this point of the code either rightnumber == rightpostion or rightnumber = rightpostion+1