vault backup: 2026-01-23 21:00:23
This commit is contained in:
10
.obsidian/workspace.json
vendored
10
.obsidian/workspace.json
vendored
@@ -157,12 +157,13 @@
|
||||
"state": {
|
||||
"type": "outline",
|
||||
"state": {
|
||||
"file": "YueQian/Homework/1.23.md",
|
||||
"followCursor": true,
|
||||
"showSearch": false,
|
||||
"searchQuery": ""
|
||||
},
|
||||
"icon": "lucide-list",
|
||||
"title": "大纲"
|
||||
"title": "1.23 的大纲"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -273,7 +274,7 @@
|
||||
}
|
||||
}
|
||||
],
|
||||
"currentTab": 2
|
||||
"currentTab": 3
|
||||
},
|
||||
{
|
||||
"id": "bf1e7d1a52b4651c",
|
||||
@@ -294,8 +295,7 @@
|
||||
}
|
||||
],
|
||||
"direction": "horizontal",
|
||||
"width": 336.5,
|
||||
"collapsed": true
|
||||
"width": 336.5
|
||||
},
|
||||
"left-ribbon": {
|
||||
"hiddenItems": {
|
||||
@@ -316,7 +316,7 @@
|
||||
"remotely-save:Remotely Save": false
|
||||
}
|
||||
},
|
||||
"active": "1fec176bb492eafb",
|
||||
"active": "5e96455aab22a229",
|
||||
"lastOpenFiles": [
|
||||
"YueQian/相关网站.md",
|
||||
"YueQian/Homework/1.23.md",
|
||||
|
||||
@@ -86,5 +86,38 @@ int main(int argc, char const *argv[])
|
||||
d. 增加输入校验:若输入的 ASCII 码超出 0-127 范围,输出 “无效的 ASCII 码”;若输入的不是单个字符,输出 “输入格式错误”;
|
||||
e. 核心要求:使用scanf的返回值判断输入是否有效,结合格式化控制符完成输入输出
|
||||
```c
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char const *argv[])
|
||||
{
|
||||
int ret = 0,cho = 0;
|
||||
char ch;
|
||||
int num;
|
||||
|
||||
printf("输入 1(字符转 ASCII)、2(ASCII 转字符):");
|
||||
scanf("%d",&cho);
|
||||
if(1 == cho)
|
||||
{
|
||||
ret = scanf(" %c",&ch);
|
||||
if(1 != ret)
|
||||
printf("输入格式错误 @__@ \n");
|
||||
else
|
||||
printf("%d\n",(int)ch);
|
||||
}
|
||||
else if(2 == cho)
|
||||
{
|
||||
scanf("%d",&num);
|
||||
if(0 <= num && 127 >= num )
|
||||
{
|
||||
printf("%c\n",(char)num);
|
||||
}
|
||||
else
|
||||
printf("无效的 ASCII 码 ^__^ \n");
|
||||
}
|
||||
else
|
||||
printf("无效值\n");
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user