顺序折线遍历二维数组
其实就是一个很简单的嵌套for循环而已,由于后期会用到,先在这里保存一下
bool flag = 0;
for (int i = 0; i < 10; i ++)
{
if (flag == 0)
{
for (int j = 0; j < 15; j ++)
{
cout<<"("<<i<<","<<j<<")"<<" ";
}
flag = 1;
}
else
{
for (int j = 14; j >= 0; j --)
{
cout<<"("<<i<<","<<j<<")"<<" ";
}
flag = 0;
}
}
效果为: