> 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/case.md).

# 大小写

### 判断大小写

```cpp
char ch;
cin >> ch;
if (ch >= 'A' && ch <= 'Z') cout << "大写";
else if (ch >= 'a' && ch <= 'z') cout << "小写";
else if (ch >= '0' && ch <= '9') cout << "数字";
```

### 转换

利用大小写字母 ASCII 相差 32：

```cpp
char c = 'g';
cout << (char)(c - 32);   // G，小写转大写
cout << (char)('G' + 32);  // g，大写转小写
```

### 用库函数（）

```cpp
#include <cctype>
char c = 'a';
toupper(c);   // 转大写
tolower(c);   // 转小写
isupper(c);   // 是否大写
islower(c);   // 是否小写
isalpha(c);   // 是否字母
isdigit(c);   // 是否数字
```

### 统计整串里的字母

```cpp
string s = "AbC";
int up = 0;
for (char c : s)
    if (isupper(c)) up++;
cout << up;   // 2
```


---

# 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/case.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.
