gpt4 book ai didi

C++ - For 循环不工作

转载 作者:行者123 更新时间:2023-11-28 02:26:40 25 4
gpt4 key购买 nike

<分区>

我正在制作的资本主义模拟器的 for 循环(用于调试)无法正常工作,因为它在 ix=0 时退出(它只执行一次循环体)。我也相信它在语法上是正确的(来自其他问题)。

这是我的代码(我省略了变量):

void print_things(String2Double b, String2Double up_cost, String2Double tFinish, string* bNames) {
// Just for debugging!
for (int ix=0;ix<(sizeof(bNames)/sizeof(bNames[0]));ix++) {
cout << "Count of business " << bNames[ix] << ": " << b[bNames[ix]] << endl;
cout << "Upgrade cost for " << bNames[ix] << ": " << up_cost[bNames[ix]] << endl;
cout << "Time to finish for " << bNames[ix] << ": " << tFinish[bNames[ix]] << endl;
cout << ix << endl;
}
}

我还让它打印了 bNames[] 的大小,它是 9,它只打印了 ix=0,我怀疑一定是出了什么问题。

谢谢!

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com