小编tqw*_*tqw的帖子

在 C++ 中使用函数参数作为循环变量

foo使用函数参数作为循环变量

void foo(int i, int j) {
    for (; i < 5; ++i)
        for (; j < 5; ++j)
            std::cout << i << " " << j << std::endl;
}
Run Code Online (Sandbox Code Playgroud)

foo(0, 0)打印

0 0
0 1
0 2
0 3
0 4
Run Code Online (Sandbox Code Playgroud)

我想知道为什么i总是0

c++ for-loop nested-loops function-definition

1
推荐指数
1
解决办法
90
查看次数

标签 统计

c++ ×1

for-loop ×1

function-definition ×1

nested-loops ×1