If statement variante

Hi, I started following the course recently. I arrived at the lesson on conditions if anything else. In the required exercise, a double iteration is used to check whether to increase cows or bulls. I’ve never thought about this technique. I did something like this:

FString input = "";
std::cin >> input;
for(int32 i = 0; i<myHiddenWord; i++)
{
   if(input[i] == myHiddenWord[i] {FBullCowCount.Bull ++;}
   
   else if(myHiddenWord[i].find(input[i])) { FBullCowCount.Cow ++;}
 
}

Privacy & Terms