From a580bebc74deb15737d005231549ff72e06b35d1 Mon Sep 17 00:00:00 2001 From: smallkun Date: Tue, 18 Mar 2025 09:23:10 +0800 Subject: [PATCH] Auto commit --- 2207/C语言同步练习源码/5.指针-3.c | 19 +++++++++++++++++++ 2207/C语言同步练习答案.md | 22 ++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 2207/C语言同步练习源码/5.指针-3.c diff --git a/2207/C语言同步练习源码/5.指针-3.c b/2207/C语言同步练习源码/5.指针-3.c new file mode 100644 index 0000000..2c1e7f3 --- /dev/null +++ b/2207/C语言同步练习源码/5.指针-3.c @@ -0,0 +1,19 @@ +#include + +int main(){ + char str[] = "AbcDEfg"; + char *p = str; + + while(*p != '\0'){ + if(*p >= 'a' && *p <= 'z'){ + *p -= 32; + }else{ + *p += 32; + } + p++; + } + puts(str); + + return 0; +} + diff --git a/2207/C语言同步练习答案.md b/2207/C语言同步练习答案.md index 15a4f74..b3b7d24 100644 --- a/2207/C语言同步练习答案.md +++ b/2207/C语言同步练习答案.md @@ -808,6 +808,28 @@ int main(){ ![image-20250227231232971](https://yp.smallkun.cn/markdown/image-20250227231232971.png!compress) +```c +#include + +int main(){ + char str[] = "AbcDEfg"; + char *p = str; + + while(*p != '\0'){ + if(*p >= 'a' && *p <= 'z'){ + *p -= 32; + }else{ + *p += 32; + } + p++; + } + puts(str); + + return 0; +} + +``` + ### 指针-4