use*_*490 0 c++ python for-loop
我理解如何使用for循环
for (x = 0 ; x<5 ; x++ ) { // some_code }
Run Code Online (Sandbox Code Playgroud)
在C++中,但是像for循环一样
for x in y:
Run Code Online (Sandbox Code Playgroud)
至少存在于python中
最接近的等价物是基于for循环的范围.例如,
auto y = {0, 1, 2, 3, 4, 5, 6};
for (auto i : y)
{
// do something with i
}
Run Code Online (Sandbox Code Playgroud)
有更多细节,但这取决于你想做什么.C++的语义与python的完全不同.