> For the complete documentation index, see [llms.txt](https://docs.1l.lol/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.1l.lol/basics/comments-debug.md).

# 注释与调试

### 注释

注释用于说明代码，不参与编译。

```cpp
// 单行注释

/*
   多行注释
   可以写多行说明
*/

int a = 10;  // 行尾注释
```

快捷键：Dev-C++ 中 `Ctrl+/` 可注释/取消注释选中行。

### 调试的常用手段

1. **输出中间结果**：在关键位置 `cout` 变量值，观察变化。
2. **断点调试**：在行号处点击设断点，运行到此处暂停，单步执行查看变量。
3. **对比样例**：用题目给的样例输入，核对输出是否一致。

### 常见错误类型

| 类型   | 说明               |
| ---- | ---------------- |
| 编译错误 | 语法错误，如少了分号、括号不匹配 |
| 运行错误 | 如除以 0、数组越界、死循环   |
| 逻辑错误 | 能运行但结果不对，需靠调试发现  |

### 调试小技巧

* 数组越界时，把数组开大一点试试。
* 输出格式错误（多空格/换行）也会判错。
* 变量未初始化是常见坑点，定义时尽量赋初值。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.1l.lol/basics/comments-debug.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
