In the program I am making the user will enter in 4 numbers ranging from 1 to 6. he will have twenty attempts to guess the correct numbers and in the correct order. to do that i need to make two void function arrays.
Code:
void calculate correct numbers
if(answer[1]==guess[0] || answer[2]==guess[0] || answer[3]==guess[0]){
correctnum++;
}
if(answer[0]==guess[1] || answer[2]==guess[1] || answer[3]==guess[1]){
correctnum++;
}
if(answer[0]==guess[2] || answer[0]==guess[2] || answer[3]==guess[2]){
correctnum++;
}
if(answer[0]==guess[3] || answer[1]==guess[3] || answer[2]==guess[3]){
correctnum++;
}
void calculate correct locations /*something!*/
if(answer[0]==guess[0]){
correctloc++;
}
if(answer[1]==guess[1]){
correctloc++;
} if(answer[2]==guess[2]){
correctloc++;
} if(answer[3]==guess[3]){
correctloc++;
}
however i was told the best way to do the "correct numbers" function is to put a for loop within a for loop, but i wasn't sure about that. i also was told that it was recommended to create a "dummy" function so that i don't get too high of a number when guessing the actual numbers. ie:
real- 1, 2, 3, 4
guess- 1, 1, 1, 4 ----> that should be two correct choices, the first guessed 1 and the 4.
any guidance would be greatly appreciated. thank you!