在 python 上我这样做
x = [1,2,3,4]
print(x)
如何将其转换为c++
我尝试这种方式,但它给了我错误
std::vector<int> x = {1,2,3,4};
cout << x;
invalid operands to binary expression ('std::__ndk1::ostream' (aka 'basic_ostream<char>') and 'std::vector<int>')
std::cout << x;
我也不会那样做
std::vector<int> x = {1,2,3,4};
for (int i: x){
std::cout << i;
}
使用以下
for (auto &e : x)
{
std::cout << e << std::endl;
}
应该可以解决问题
它只是浏览列表