# C++每日一题 Day 7 贪吃蛇

***

lhy版权所有，禁止转载

### 知识点：二维数组、循环

***

## 题目描述

有一天某人无聊，用班上的西沃电脑做了一个很无聊的贪吃蛇游戏。贪吃蛇游戏的地图由 n\*n 个格子组成。阿肝看到了这个游戏，打算控制小蛇从左上角的点开始，沿上边往右前进到不能前进为止，然后转向下走，前进到不能前进为止，再向左走，前进到不能前进为止，再向上走... 总之，因为某人和阿肝都很无聊，所以他们决定用这种方式让小蛇爬过这个地图的每一个格子。

下面给出n，请输出各个格子被小蛇爬过的次序。

## 输入

一个整数n（<10）

## 输出

n\*n 的整数方阵，表示各点被爬过的次序

## 输入输出样例

### 输入

```
4
```

输出

```
  1  2  3  4
 12 13 14  5
 11 16 15  6
 10  9  8  7
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://blog.mcyou.cc/c++-mei-ri-yi-ti/c++-mei-ri-yi-ti-day-7-tan-chi-she.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
