我不明白为什么我在这种情况下使用字母 i

I don't Understand why I'm using the letter i in this situation

本文关键字:这种情况下 明白 为什么      更新时间:2023-10-16

我刚刚开始在c++和工作在一个简单的控制台应用程序,和教练没有解释一些事情。在这一部分中,他说要编码

//increment the turn number
MyCurrentTry++;
//setup a return variable
FBullCowCount BullCowCount;
//loop through all letters in the guess
int32 HiddenWordLenth = MyHiddenWord.length();
for (int32 i = 0; i < HiddenWordLenth; i++) {
    // compare letters against the hidden word
    for (int32 j = 0; j < HiddenWordLenth; j++) {
        // if they match then       
        if (Guess[i] == MyHiddenWord[i]) { //if they're in the same place
            if (i == j) { // increment bulls 
                BullCowCount.Bulls++; // Incriment Bulls
            }
            else
            {
                BullCowCount.Cows++; //must be a cow
            }

现在我明白这有点乱(对不起),但如果有人能解释为什么我使用ii做什么(它是某种变量,还是什么?),我会非常感激。如果我的问题不清楚或者我做错了什么,请告诉我(老师说这个"I"最终会产生一个bug,但我想知道它的目的)

ij只是for循环中的反变量。他们也可以被命名为ingridjohn。它们的唯一用途是在循环迭代时充当计数器。