如何实现此C++代码中的轮数?

How do I implement the number of rounds in this C++ code?

本文关键字:代码 C++ 何实现 实现      更新时间:2024-05-10
int round;
int Starting_index;
int hop_count;
for( round = 0; round < gNumRounds; round++)
{
Starting_index[round] = gPasswordHash[0+round*4] * 256 + gPasswordHash[1+round*4];
hop_count [round] = gPasswordHash[2+round*4] * 256 + gPasswordHash[3+round*4];
if(hop_count == 0) hop_count = 0xFFFF;
}

gPasswordHashgNumRounds都是全局变量。我遇到错误的地方是在for循环中设置Starting_index[round]hop_count[round]

我的Starting_indexhop_count声明可能有问题,但我不确定那是什么。

您需要将这些变量声明为数组,而不是单个int

int Starting_index[MAXROUNDS];
int hop_count[MAXROUNDS];

Starting_index和hop_count没有声明为数组,它们目前只是整数。您还应该在 for 循环声明中声明和定义 round,而不是更早的:"for (int round = 0;round <gNumRounds;>

我真的不知道你说的"如果(hop_count== 0)hop_count = 0xFFFF;"是什么意思。