void getPos(Pos* around,int row,int column,int index){
int flag;
if (row % 2 == 0) {
flag = 0;
}else{
flag = 1;
}
// 先获取 row 行
int cursor = 0;
around[cursor].row = row;
around[cursor].column = column - index;
++cursor;
around[cursor].row = row;
around[cursor].column = column + index;
++cursor;
// row 上一行
around[cursor].row = row-1;
around[cursor].column = around[0].column + flag;
++cursor;
around[cursor].row = row-1;
around[cursor].column = around[cursor-1].column + (2*index-1);
++cursor;
int counter = 1 + flag;
if (counter == 2) {
counter = 0;
}
int lastCursor = 2;
for (int i = 2; i <= index; ++i) {
if (i == index) {
around[cursor].row = row - i;
around[cursor].column = around[lastCursor].column + counter;
++cursor;
for (int k = 1; k < index + 1; ++k) {
around[cursor].row = row - i;
around[cursor].column = around[cursor-1].column + 1;
++cursor;
}
break;
}else{
around[cursor].row = row - i;
around[cursor].column = around[lastCursor].column + counter;
++cursor;
around[cursor].row = row - i;
around[cursor].column = around[cursor-1].column + (2 * index - i);
++cursor;
lastCursor += 2;
}
++counter;
if (counter == 2) {
counter = 0;
}
}
/////////////////////////////////////////
/// 中间行的下一行
around[cursor].row = row + 1;
around[cursor].column = around[0].column + flag;
++cursor;
around[cursor].row = row + 1;
around[cursor].column = around[cursor-1].column + (2*index-1);
++cursor;
counter = 1 + flag;
if (counter == 2) {
counter = 0;
}
lastCursor = index * 3 + 1;
for (int i = 2; i <= index ; ++i) {
if (i == index) {
around[cursor].row = row + i;
around[cursor].column = around[lastCursor].column + counter;
++cursor;
for (int k = 1; k < index + 1; ++k) {
around[cursor].row = row + i;
around[cursor].column = around[cursor-1].column + 1;
++cursor;
}
break;
}else{
around[cursor].row = row + i;
around[cursor].column = around[lastCursor].column + counter;
++cursor;
around[cursor].row = row + i;
around[cursor].column = around[cursor-1].column + (2 * index - i);
++cursor;
lastCursor += 2;
}
++counter;
if (counter == 2) {
counter = 0;
}
}
}