我想在打印出某些索引 [0]、v[2]、v[6]、v[14] 后打印一个新行。增量 2^(n+1)
for (int i = 0; i < v2.size(); i++)
{
std::cout << v2[i] << " ";
// need to print a new line after done printing v[0], v[2], v[6], v[14]
}
我尝试了硬编码if(i== 0 || i == 2 || i == 4 || .. || i == 30)
,但似乎效率不高。有什么建议么?