Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
CSDN 技术社区
skill_tree_c
提交
6ff49511
S
skill_tree_c
项目概览
CSDN 技术社区
/
skill_tree_c
通知
24
Star
4
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
skill_tree_c
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
6ff49511
编写于
10月 21, 2021
作者:
L
luxin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add 6 exercises
上级
48d47ca5
变更
34
隐藏空白更改
内联
并排
Showing
34 changed file
with
1053 addition
and
60 deletion
+1053
-60
data/2.C语言中阶/1.函数与程序结构/1.函数的声明与定义/config.json
data/2.C语言中阶/1.函数与程序结构/1.函数的声明与定义/config.json
+2
-1
data/2.C语言中阶/1.函数与程序结构/1.函数的声明与定义/definition.c
data/2.C语言中阶/1.函数与程序结构/1.函数的声明与定义/definition.c
+22
-0
data/2.C语言中阶/1.函数与程序结构/1.函数的声明与定义/definition.json
data/2.C语言中阶/1.函数与程序结构/1.函数的声明与定义/definition.json
+7
-0
data/2.C语言中阶/1.函数与程序结构/1.函数的声明与定义/definition.md
data/2.C语言中阶/1.函数与程序结构/1.函数的声明与定义/definition.md
+104
-0
data/2.C语言中阶/1.函数与程序结构/3.函数的返回/config.json
data/2.C语言中阶/1.函数与程序结构/3.函数的返回/config.json
+2
-1
data/2.C语言中阶/1.函数与程序结构/3.函数的返回/return.json
data/2.C语言中阶/1.函数与程序结构/3.函数的返回/return.json
+5
-1
data/2.C语言中阶/1.函数与程序结构/3.函数的返回/return.md
data/2.C语言中阶/1.函数与程序结构/3.函数的返回/return.md
+3
-45
data/2.C语言中阶/1.函数与程序结构/4.函数的调用/config.json
data/2.C语言中阶/1.函数与程序结构/4.函数的调用/config.json
+2
-1
data/2.C语言中阶/1.函数与程序结构/4.函数的调用/function_call.c
data/2.C语言中阶/1.函数与程序结构/4.函数的调用/function_call.c
+35
-0
data/2.C语言中阶/1.函数与程序结构/4.函数的调用/function_call.json
data/2.C语言中阶/1.函数与程序结构/4.函数的调用/function_call.json
+7
-0
data/2.C语言中阶/1.函数与程序结构/4.函数的调用/function_call.md
data/2.C语言中阶/1.函数与程序结构/4.函数的调用/function_call.md
+167
-0
data/2.C语言中阶/1.函数与程序结构/6.局部变量和全局变量/config.json
data/2.C语言中阶/1.函数与程序结构/6.局部变量和全局变量/config.json
+11
-0
data/2.C语言中阶/1.函数与程序结构/6.局部变量和全局变量/global_n_local_var.c
data/2.C语言中阶/1.函数与程序结构/6.局部变量和全局变量/global_n_local_var.c
+26
-0
data/2.C语言中阶/1.函数与程序结构/6.局部变量和全局变量/global_n_local_var.json
data/2.C语言中阶/1.函数与程序结构/6.局部变量和全局变量/global_n_local_var.json
+7
-0
data/2.C语言中阶/1.函数与程序结构/6.局部变量和全局变量/global_n_local_var.md
data/2.C语言中阶/1.函数与程序结构/6.局部变量和全局变量/global_n_local_var.md
+118
-0
data/2.C语言中阶/1.函数与程序结构/7.头文件/config.json
data/2.C语言中阶/1.函数与程序结构/7.头文件/config.json
+0
-0
data/2.C语言中阶/1.函数与程序结构/8.内部函数和外部函数/config.json
data/2.C语言中阶/1.函数与程序结构/8.内部函数和外部函数/config.json
+0
-0
data/2.C语言中阶/3.指针/5.指针数组以及指向指针的指针/config.json
data/2.C语言中阶/3.指针/5.指针数组以及指向指针的指针/config.json
+2
-1
data/2.C语言中阶/3.指针/5.指针数组以及指向指针的指针/pointers_array.c
data/2.C语言中阶/3.指针/5.指针数组以及指向指针的指针/pointers_array.c
+21
-0
data/2.C语言中阶/3.指针/5.指针数组以及指向指针的指针/pointers_array.json
data/2.C语言中阶/3.指针/5.指针数组以及指向指针的指针/pointers_array.json
+7
-0
data/2.C语言中阶/3.指针/5.指针数组以及指向指针的指针/pointers_array.md
data/2.C语言中阶/3.指针/5.指针数组以及指向指针的指针/pointers_array.md
+103
-0
data/2.C语言中阶/3.指针/6.指向函数的指针/config.json
data/2.C语言中阶/3.指针/6.指向函数的指针/config.json
+0
-0
data/2.C语言中阶/3.指针/6.指向函数的指针/pointers_2_func.c
data/2.C语言中阶/3.指针/6.指向函数的指针/pointers_2_func.c
+0
-0
data/2.C语言中阶/3.指针/6.指向函数的指针/pointers_2_func.json
data/2.C语言中阶/3.指针/6.指向函数的指针/pointers_2_func.json
+0
-0
data/2.C语言中阶/3.指针/6.指向函数的指针/pointers_2_func.md
data/2.C语言中阶/3.指针/6.指向函数的指针/pointers_2_func.md
+0
-0
data/2.C语言中阶/3.指针/6.指针数组以及指向指针的指针/config.json
data/2.C语言中阶/3.指针/6.指针数组以及指向指针的指针/config.json
+0
-10
data/2.C语言中阶/4.字符串/1.字符串输入与输出/config.json
data/2.C语言中阶/4.字符串/1.字符串输入与输出/config.json
+10
-0
data/2.C语言中阶/4.字符串/1.字符串输入与输出/string_io.c
data/2.C语言中阶/4.字符串/1.字符串输入与输出/string_io.c
+33
-0
data/2.C语言中阶/4.字符串/1.字符串输入与输出/string_io.json
data/2.C语言中阶/4.字符串/1.字符串输入与输出/string_io.json
+7
-0
data/2.C语言中阶/4.字符串/1.字符串输入与输出/string_io.md
data/2.C语言中阶/4.字符串/1.字符串输入与输出/string_io.md
+147
-0
data/2.C语言中阶/4.字符串/2.字符串函数/config.json
data/2.C语言中阶/4.字符串/2.字符串函数/config.json
+12
-0
data/2.C语言中阶/4.字符串/2.字符串函数/string_func.c
data/2.C语言中阶/4.字符串/2.字符串函数/string_func.c
+32
-0
data/2.C语言中阶/4.字符串/2.字符串函数/string_func.json
data/2.C语言中阶/4.字符串/2.字符串函数/string_func.json
+7
-0
data/2.C语言中阶/4.字符串/2.字符串函数/string_func.md
data/2.C语言中阶/4.字符串/2.字符串函数/string_func.md
+154
-0
未找到文件。
data/2.C语言中阶/1.函数与程序结构/1.函数的声明与定义/config.json
浏览文件 @
6ff49511
...
@@ -6,5 +6,5 @@
...
@@ -6,5 +6,5 @@
"C语言"
"C语言"
],
],
"children"
:
[],
"children"
:
[],
"export"
:
[]
"export"
:
[
"definition.json"
]
}
}
\ No newline at end of file
data/2.C语言中阶/1.函数与程序结构/1.函数的声明与定义/definition.c
0 → 100644
浏览文件 @
6ff49511
#include <stdio.h>
void
print_link
();
void
print_skill_tree
();
int
main
()
{
print_skill_tree
();
return
0
;
}
void
print_link
()
{
printf
(
"https://bbs.csdn.net/skill/c"
);
}
void
print_skill_tree
()
{
printf
(
"欢迎访问
\"
C语言技能树
\"
网址:"
);
print_link
();
}
\ No newline at end of file
data/2.C语言中阶/1.函数与程序结构/1.函数的声明与定义/definition.json
0 → 100644
浏览文件 @
6ff49511
{
"type"
:
"code_options"
,
"author"
:
"卢昕"
,
"source"
:
"definition.md"
,
"exercise_id"
:
"7c71b281a3c5490e95f9ab3c99d110f0"
}
\ No newline at end of file
data/2.C语言中阶/1.函数与程序结构/1.函数的声明与定义/definition.md
0 → 100644
浏览文件 @
6ff49511
# 打印技能树名称和网址
定义两个函数,打印C语言技能树的名称和网址。请选出正确答案。
## 答案
```
c
#include <stdio.h>
void
print_link
();
void
print_skill_tree
();
int
main
()
{
print_skill_tree
();
return
0
;
}
void
print_link
()
{
printf
(
"https://bbs.csdn.net/skill/c"
);
}
void
print_skill_tree
()
{
printf
(
"欢迎访问
\"
C语言技能树
\"
网址:"
);
print_link
();
}
```
## 选项
### A
```
c
#include <stdio.h>
void
print_skill_tree
()
{
printf
(
"欢迎访问
\"
C语言技能树
\"
网址:"
);
print_link
();
}
void
print_link
()
{
printf
(
"https://bbs.csdn.net/skill/c"
);
}
int
main
()
{
print_skill_tree
();
return
0
;
}
```
### B
```
c
#include <stdio.h>
void
print_link
();
void
print_skill_tree
();
int
main
()
{
print_skill_tree
();
return
0
;
}
void
print_skill_tree
()
{
printf
(
"欢迎访问
\"
C语言技能树
\"
网址:"
);
void
print_link
()
{
printf
(
"https://bbs.csdn.net/skill/c"
);
}
print_link
();
}
```
### C
```
c
#include <stdio.h>
void
print_link
(
char
);
void
print_skill_tree
();
int
main
()
{
print_skill_tree
();
return
0
;
}
void
print_link
(
char
link
[])
{
printf
(
"%s"
,
link
);
}
void
print_skill_tree
()
{
printf
(
"欢迎访问
\"
C语言技能树
\"
网址:"
);
print_link
(
"https://bbs.csdn.net/skill/c"
);
}
```
data/2.C语言中阶/1.函数与程序结构/3.函数的返回/config.json
浏览文件 @
6ff49511
...
@@ -6,5 +6,5 @@
...
@@ -6,5 +6,5 @@
"C语言"
"C语言"
],
],
"children"
:
[],
"children"
:
[],
"export"
:
[]
"export"
:
[
"return.json"
]
}
}
\ No newline at end of file
data/2.C语言中阶/1.函数与程序结构/3.函数的返回/return.json
浏览文件 @
6ff49511
{
{
"type"
:
"code_options"
,
"author"
:
"卢昕"
,
"source"
:
"return.md"
,
"exercise_id"
:
"c08cb53f455d47fbbf244d2605f5ae6d"
}
}
\ No newline at end of file
data/2.C语言中阶/1.函数与程序结构/3.函数的返回/return.md
浏览文件 @
6ff49511
...
@@ -48,50 +48,8 @@ int main()
...
@@ -48,50 +48,8 @@ int main()
## 选项
## 选项
### A
```
c
#include <stdio.h>
void
prime
(
int
n
)
{
int
is_prime
=
1
,
i
;
if
(
n
<
0
)
### A
{
printf
(
"%d 是一个非法输入!
\n
"
,
n
);
return
-
1
;
}
else
if
(
n
<
2
)
{
printf
(
"%d 不是一个素数!
\n
"
,
n
);
return
0
;
}
for
(
i
=
2
;
i
<
n
;
i
++
)
if
(
n
%
i
==
0
)
{
is_prime
=
0
;
break
;
}
if
(
is_prime
==
1
)
printf
(
"%d 是一个素数!
\n
"
,
n
);
else
printf
(
"%d 不是一个素数!
\n
"
,
n
);
}
int
main
()
{
int
num
,
is_prime
;
printf
(
"请输入一个整数:"
);
scanf
(
"%d"
,
&
num
);
prime
(
num
);
return
0
;
}
```
### B
```
c
```
c
#include <stdio.h>
#include <stdio.h>
...
@@ -132,7 +90,7 @@ int main()
...
@@ -132,7 +90,7 @@ int main()
}
}
```
```
###
C
###
B
```
c
```
c
#include <stdio.h>
#include <stdio.h>
...
@@ -175,7 +133,7 @@ int main()
...
@@ -175,7 +133,7 @@ int main()
}
}
```
```
###
D
###
C
```
c
```
c
#include <stdio.h>
#include <stdio.h>
...
...
data/2.C语言中阶/1.函数与程序结构/4.函数的调用/config.json
浏览文件 @
6ff49511
...
@@ -6,5 +6,5 @@
...
@@ -6,5 +6,5 @@
"C语言"
"C语言"
],
],
"children"
:
[],
"children"
:
[],
"export"
:
[]
"export"
:
[
"function_call.json"
]
}
}
\ No newline at end of file
data/2.C语言中阶/1.函数与程序结构/4.函数的调用/function_call.c
0 → 100644
浏览文件 @
6ff49511
#include <stdio.h>
char
*
csdn
()
{
return
"CSDN-->"
;
}
char
*
yueluqu
()
{
return
"岳麓区-->"
;
}
char
*
changsha
()
{
return
"长沙-->"
;
}
char
*
hunan
()
{
return
"湖南-->"
;
}
char
*
china
()
{
return
"中国-->"
;
}
int
main
()
{
printf
(
"%s%s%s%s%s"
,
china
(),
hunan
(),
changsha
(),
yueluqu
(),
csdn
());
printf
(
"https://www.csdn.net/"
);
return
0
;
}
\ No newline at end of file
data/2.C语言中阶/1.函数与程序结构/4.函数的调用/function_call.json
0 → 100644
浏览文件 @
6ff49511
{
"type"
:
"code_options"
,
"author"
:
"卢昕"
,
"source"
:
"function_call.md"
,
"exercise_id"
:
"41843efba027453c9f2eea82d794cdf6"
}
\ No newline at end of file
data/2.C语言中阶/1.函数与程序结构/4.函数的调用/function_call.md
0 → 100644
浏览文件 @
6ff49511
# 打印函数调用顺序
基于函数调用的顺序,正确输出
**中国-->湖南-->长沙-->岳麓区-->CSDN-->https://www.csdn.net/**
。请选出错误答案。
## 答案
```
c
#include <stdio.h>
void
csdn
()
{
printf
(
"CSDN-->"
);
}
void
yueluqu
()
{
printf
(
"岳麓区-->"
);
csdn
();
}
void
changsha
()
{
printf
(
"长沙-->"
);
yueluqu
();
}
void
hunan
()
{
printf
(
"湖南-->"
);
changsha
();
}
void
china
()
{
printf
(
"中国-->"
);
hunan
();
}
china
();
printf
(
"https://www.csdn.net/"
);
int
main
()
{
return
0
;
}
```
## 选项
### A
```
c
#include <stdio.h>
void
csdn
()
{
printf
(
"CSDN-->"
);
}
void
yueluqu
()
{
printf
(
"岳麓区-->"
);
}
void
changsha
()
{
printf
(
"长沙-->"
);
}
void
hunan
()
{
printf
(
"湖南-->"
);
}
void
china
()
{
printf
(
"中国-->"
);
}
int
main
()
{
china
();
hunan
();
changsha
();
yueluqu
();
csdn
();
printf
(
"https://www.csdn.net/"
);
return
0
;
}
```
### B
```
c
#include <stdio.h>
void
csdn
()
{
printf
(
"CSDN-->"
);
}
void
yueluqu
()
{
printf
(
"岳麓区-->"
);
csdn
();
}
void
changsha
()
{
printf
(
"长沙-->"
);
yueluqu
();
}
void
hunan
()
{
printf
(
"湖南-->"
);
changsha
();
}
void
china
()
{
printf
(
"中国-->"
);
}
int
main
()
{
china
();
printf
(
"https://www.csdn.net/"
);
return
0
;
}
```
### C
```
c
#include <stdio.h>
char
*
csdn
()
{
return
"CSDN-->"
;
}
char
*
yueluqu
()
{
return
"岳麓区-->"
;
}
char
*
changsha
()
{
return
"长沙-->"
;
}
char
*
hunan
()
{
return
"湖南-->"
;
}
char
*
china
()
{
return
"中国-->"
;
}
int
main
()
{
printf
(
"%s%s%s%s%s"
,
china
(),
hunan
(),
changsha
(),
yueluqu
(),
csdn
());
printf
(
"https://www.csdn.net/"
);
return
0
;
}
```
data/2.C语言中阶/1.函数与程序结构/6.局部变量和全局变量/config.json
0 → 100644
浏览文件 @
6ff49511
{
"node_id"
:
"569d5e11c4fc5de7844053d9a733c5e8"
,
"keywords"
:
[
"C语言概述"
,
"概述"
,
"C语言"
],
"children"
:
[],
"export"
:
[
"global_n_local_var.json"
]
}
\ No newline at end of file
data/2.C语言中阶/1.函数与程序结构/6.局部变量和全局变量/global_n_local_var.c
0 → 100644
浏览文件 @
6ff49511
#include <stdio.h>
int
s1
,
s2
,
s3
;
int
vs
(
int
a
,
int
b
,
int
c
)
{
int
v
;
v
=
a
*
b
*
c
;
s1
=
a
*
b
;
s2
=
b
*
c
;
s3
=
a
*
c
;
return
v
;
}
int
main
()
{
int
v
,
length
,
width
,
height
;
printf
(
"请分别输入长方体的长宽高:"
);
scanf
(
"%d,%d,%d"
,
&
length
,
&
width
,
&
height
);
v
=
vs
(
length
,
width
,
height
);
printf
(
"v=%d, s1=%d, s2=%d, s3=%d
\n
"
,
v
,
s1
,
s2
,
s3
);
return
0
;
}
\ No newline at end of file
data/2.C语言中阶/1.函数与程序结构/6.局部变量和全局变量/global_n_local_var.json
0 → 100644
浏览文件 @
6ff49511
{
"type"
:
"code_options"
,
"author"
:
"卢昕"
,
"source"
:
"global_n_local_var.md"
,
"exercise_id"
:
"8c862340818547858499a071f828bbba"
}
\ No newline at end of file
data/2.C语言中阶/1.函数与程序结构/6.局部变量和全局变量/global_n_local_var.md
0 → 100644
浏览文件 @
6ff49511
# 长方体的体积和面积
根据长方体的长宽高求它的体积以及三个面的面积。找出正确的选项。
## 答案
```
c
#include <stdio.h>
int
s1
,
s2
,
s3
;
int
vs
(
int
a
,
int
b
,
int
c
)
{
int
v
;
v
=
a
*
b
*
c
;
s1
=
a
*
b
;
s2
=
b
*
c
;
s3
=
a
*
c
;
return
v
;
}
int
main
()
{
int
v
,
length
,
width
,
height
;
printf
(
"请分别输入长方体的长宽高:"
);
scanf
(
"%d,%d,%d"
,
&
length
,
&
width
,
&
height
);
v
=
vs
(
length
,
width
,
height
);
printf
(
"v=%d, s1=%d, s2=%d, s3=%d
\n
"
,
v
,
s1
,
s2
,
s3
);
return
0
;
}
```
## 选项
### A
```
c
#include <stdio.h>
int
vs
(
int
a
,
int
b
,
int
c
)
{
int
v
;
v
=
a
*
b
*
c
;
s1
=
a
*
b
;
s2
=
b
*
c
;
s3
=
a
*
c
;
return
v
;
}
int
s1
,
s2
,
s3
;
int
main
()
{
int
v
,
length
,
width
,
height
;
printf
(
"请分别输入长方体的长宽高:"
);
scanf
(
"%d,%d,%d"
,
&
length
,
&
width
,
&
height
);
v
=
vs
(
length
,
width
,
height
);
printf
(
"v=%d, s1=%d, s2=%d, s3=%d
\n
"
,
v
,
s1
,
s2
,
s3
);
return
0
;
}
```
### B
```
c
#include <stdio.h>
int
vs
(
int
a
,
int
b
,
int
c
)
{
int
v
,
s1
,
s2
,
s3
;
v
=
a
*
b
*
c
;
s1
=
a
*
b
;
s2
=
b
*
c
;
s3
=
a
*
c
;
return
v
;
}
int
main
()
{
int
v
,
length
,
width
,
height
;
printf
(
"请分别输入长方体的长宽高:"
);
scanf
(
"%d,%d,%d"
,
&
length
,
&
width
,
&
height
);
v
=
vs
(
length
,
width
,
height
);
printf
(
"v=%d, s1=%d, s2=%d, s3=%d
\n
"
,
v
,
s1
,
s2
,
s3
);
return
0
;
}
```
### C
```
c
#include <stdio.h>
int
s1
,
s2
,
s3
;
int
vs
(
int
a
,
int
b
,
int
c
)
{
int
v
,
s1
,
s2
,
s3
;
v
=
a
*
b
*
c
;
s1
=
a
*
b
;
s2
=
b
*
c
;
s3
=
a
*
c
;
return
v
;
}
int
main
()
{
int
v
,
length
,
width
,
height
;
printf
(
"请分别输入长方体的长宽高:"
);
scanf
(
"%d,%d,%d"
,
&
length
,
&
width
,
&
height
);
v
=
vs
(
length
,
width
,
height
);
printf
(
"v=%d, s1=%d, s2=%d, s3=%d
\n
"
,
v
,
s1
,
s2
,
s3
);
return
0
;
}
```
data/2.C语言中阶/1.函数与程序结构/
6.内部函数和外部函数
/config.json
→
data/2.C语言中阶/1.函数与程序结构/
7.头文件
/config.json
浏览文件 @
6ff49511
文件已移动
data/2.C语言中阶/1.函数与程序结构/8.
头文件
/config.json
→
data/2.C语言中阶/1.函数与程序结构/8.
内部函数和外部函数
/config.json
浏览文件 @
6ff49511
文件已移动
data/2.C语言中阶/3.指针/5.
字符指针与函数
/config.json
→
data/2.C语言中阶/3.指针/5.
指针数组以及指向指针的指针
/config.json
浏览文件 @
6ff49511
...
@@ -5,5 +5,5 @@
...
@@ -5,5 +5,5 @@
"C语言"
"C语言"
],
],
"children"
:
[],
"children"
:
[],
"export"
:
[]
"export"
:
[
"pointers_array.json"
]
}
}
\ No newline at end of file
data/2.C语言中阶/3.指针/5.指针数组以及指向指针的指针/pointers_array.c
0 → 100644
浏览文件 @
6ff49511
#include <stdio.h>
#define LEN 5
int
main
()
{
char
*
fruits
[
LEN
]
=
{
"apple"
,
"cherry"
,
"grape"
,
"peach"
,
"watermelon"
};
for
(
int
i
=
0
;
i
<
LEN
;
++
fruits
,
++
i
)
{
printf
(
"%s
\n
"
,
*
fruits
);
}
return
0
;
}
\ No newline at end of file
data/2.C语言中阶/3.指针/5.指针数组以及指向指针的指针/pointers_array.json
0 → 100644
浏览文件 @
6ff49511
{
"type"
:
"code_options"
,
"author"
:
"卢昕"
,
"source"
:
"pointers_array.md"
,
"exercise_id"
:
"7c21ed88658c4513a24afbc96d043028"
}
\ No newline at end of file
data/2.C语言中阶/3.指针/5.指针数组以及指向指针的指针/pointers_array.md
0 → 100644
浏览文件 @
6ff49511
# 打印字符串数组中的所有词
给定一个字符串数组,打印数组中的所有词。请选出错误答案。
## 答案
```
c
#include <stdio.h>
#define LEN 5
int
main
()
{
char
*
fruits
[
LEN
]
=
{
"apple"
,
"cherry"
,
"grape"
,
"peach"
,
"watermelon"
};
for
(
int
i
=
0
;
i
<
LEN
;
++
fruits
,
++
i
)
{
printf
(
"%s
\n
"
,
*
fruits
);
}
return
0
;
}
```
## 选项
### A
```
c
#include <stdio.h>
#define LEN 5
int
main
()
{
char
*
fruits
[
LEN
]
=
{
"apple"
,
"cherry"
,
"grape"
,
"peach"
,
"watermelon"
};
for
(
int
i
=
0
;
i
<
LEN
;
++
i
)
{
printf
(
"%s
\n
"
,
fruits
[
i
]);
}
return
0
;
}
```
### B
```
c
#include <stdio.h>
#define LEN 5
int
main
()
{
char
*
fruits
[
LEN
]
=
{
"apple"
,
"cherry"
,
"grape"
,
"peach"
,
"watermelon"
};
char
**
ptr
=
fruits
;
for
(
int
i
=
0
;
i
<
LEN
;
++
ptr
,
++
i
)
{
printf
(
"%s
\n
"
,
*
ptr
);
}
return
0
;
}
```
### C
```
c
#include <stdio.h>
#define LEN 5
int
main
()
{
char
*
fruits
[
LEN
]
=
{
"apple"
,
"cherry"
,
"grape"
,
"peach"
,
"watermelon"
};
for
(
int
i
=
0
;
i
<
LEN
;
++
i
)
{
for
(
int
j
=
0
;
fruits
[
i
][
j
]
!=
'\0'
;
++
j
)
printf
(
"%c"
,
*
(
*
(
fruits
+
i
)
+
j
));
printf
(
"
\n
"
);
}
return
0
;
}
```
data/2.C语言中阶/3.指针/
7
.指向函数的指针/config.json
→
data/2.C语言中阶/3.指针/
6
.指向函数的指针/config.json
浏览文件 @
6ff49511
文件已移动
data/2.C语言中阶/3.指针/
7
.指向函数的指针/pointers_2_func.c
→
data/2.C语言中阶/3.指针/
6
.指向函数的指针/pointers_2_func.c
浏览文件 @
6ff49511
文件已移动
data/2.C语言中阶/3.指针/
7
.指向函数的指针/pointers_2_func.json
→
data/2.C语言中阶/3.指针/
6
.指向函数的指针/pointers_2_func.json
浏览文件 @
6ff49511
文件已移动
data/2.C语言中阶/3.指针/
7
.指向函数的指针/pointers_2_func.md
→
data/2.C语言中阶/3.指针/
6
.指向函数的指针/pointers_2_func.md
浏览文件 @
6ff49511
文件已移动
data/2.C语言中阶/3.指针/6.指针数组以及指向指针的指针/config.json
已删除
100644 → 0
浏览文件 @
48d47ca5
{
"node_id"
:
"569d5e11c4fc5de7844053d9a733c5e8"
,
"keywords"
:
[
"指针"
,
"C语言"
],
"children"
:
[],
"export"
:
[]
}
\ No newline at end of file
data/2.C语言中阶/4.字符串/1.字符串输入与输出/config.json
0 → 100644
浏览文件 @
6ff49511
{
"keywords"
:
[
"C语言概述"
,
"概述"
,
"C语言"
],
"children"
:
[],
"export"
:
[
"string_io.json"
]
}
\ No newline at end of file
data/2.C语言中阶/4.字符串/1.字符串输入与输出/string_io.c
0 → 100644
浏览文件 @
6ff49511
#include <stdio.h>
#define STR_LEN 101
void
reverse
(
char
*
str
)
{
char
*
head
=
str
;
char
*
tail
=
str
;
char
ch
;
while
(
*
tail
++
);
tail
-=
2
;
while
(
head
<
tail
)
{
ch
=
*
head
;
*
head
++
=
*
tail
;
*
tail
--
=
ch
;
}
}
int
main
()
{
char
str
[
STR_LEN
];
char
*
rev_str
=
NULL
;
fputc
(
"请输入一个字符串(length<=100):"
,
stdout
);
fgetc
(
str
);
reverse
(
str
);
fputc
(
"反转后的字符串为:"
,
stdout
);
fputc
(
str
,
stdout
);
return
0
;
}
\ No newline at end of file
data/2.C语言中阶/4.字符串/1.字符串输入与输出/string_io.json
0 → 100644
浏览文件 @
6ff49511
{
"type"
:
"code_options"
,
"author"
:
"卢昕"
,
"source"
:
"string_io.md"
,
"exercise_id"
:
"228416f6eaa44195810950a1f41de7a4"
}
\ No newline at end of file
data/2.C语言中阶/4.字符串/1.字符串输入与输出/string_io.md
0 → 100644
浏览文件 @
6ff49511
# 字符串输入与输出
输入一个字符串,并反向输出。请选出错误答案。
## 答案
```
c
#include <stdio.h>
#define STR_LEN 101
void
reverse
(
char
*
str
)
{
char
*
head
=
str
;
char
*
tail
=
str
;
char
ch
;
while
(
*
tail
++
);
tail
-=
2
;
while
(
head
<
tail
)
{
ch
=
*
head
;
*
head
++
=
*
tail
;
*
tail
--
=
ch
;
}
}
int
main
()
{
char
str
[
STR_LEN
];
char
*
rev_str
=
NULL
;
fputc
(
"请输入一个字符串(length<=100):"
,
stdout
);
fgetc
(
str
);
reverse
(
str
);
fputc
(
"反转后的字符串为:"
,
stdout
);
fputc
(
str
,
stdout
);
return
0
;
}
```
## 选项
### A
```
c
#include <stdio.h>
#define STR_LEN 101
void
reverse
(
char
*
str
)
{
char
*
head
=
str
;
char
*
tail
=
str
;
char
ch
;
while
(
*
tail
++
);
tail
-=
2
;
while
(
head
<
tail
)
{
ch
=
*
head
;
*
head
++
=
*
tail
;
*
tail
--
=
ch
;
}
}
int
main
()
{
char
str
[
STR_LEN
];
char
*
rev_str
=
NULL
;
puts
(
"请输入一个字符串(length<=100):"
);
gets
(
str
);
reverse
(
str
);
puts
(
"反转后的字符串为:"
);
puts
(
str
);
return
0
;
}
```
### B
```
c
#include <stdio.h>
#define STR_LEN 101
void
reverse
(
char
*
str
)
{
char
*
head
=
str
;
char
*
tail
=
str
;
char
ch
;
while
(
*
tail
++
);
tail
-=
2
;
while
(
head
<
tail
)
{
ch
=
*
head
;
*
head
++
=
*
tail
;
*
tail
--
=
ch
;
}
}
int
main
()
{
char
str
[
STR_LEN
];
char
*
rev_str
=
NULL
;
printf
(
"请输入一个字符串(length<=100):
\n
"
);
scanf
(
"%s"
,
str
);
reverse
(
str
);
printf
(
"反转后的字符串为:
\n
%s"
,
str
);
return
0
;
}
```
### C
```
c
#include <stdio.h>
#define STR_LEN 101
void
reverse
(
char
*
str
)
{
char
*
head
=
str
;
char
*
tail
=
str
;
char
ch
;
while
(
*
tail
++
);
tail
-=
2
;
while
(
head
<
tail
)
{
ch
=
*
head
;
*
head
++
=
*
tail
;
*
tail
--
=
ch
;
}
}
int
main
()
{
char
str
[
STR_LEN
];
char
*
rev_str
=
NULL
;
fputs
(
"请输入一个字符串(length<=100):
\n
"
,
stdout
);
fgets
(
str
,
STR_LEN
,
stdin
);
reverse
(
str
);
fputs
(
"反转后的字符串为:"
,
stdout
);
fputs
(
str
,
stdout
);
return
0
;
}
```
data/2.C语言中阶/4.字符串/2.字符串函数/config.json
0 → 100644
浏览文件 @
6ff49511
{
"keywords"
:
[
"C语言概述"
,
"概述"
,
"C语言"
],
"children"
:
[],
"export"
:
[
"string_func.json"
]
}
\ No newline at end of file
data/2.C语言中阶/4.字符串/2.字符串函数/string_func.c
0 → 100644
浏览文件 @
6ff49511
#include <stdio.h>
#include <string.h>
#define SENT_LEN 5
#define WORDS_NUM 2
#define STR_LEN 101
int
main
()
{
int
i
,
j
;
char
words
[
SENT_LEN
][
STR_LEN
]
=
{
"非"
,
"淡泊"
,
"无以"
,
"明志"
,
"!"
};
char
source
[
WORDS_NUM
][
STR_LEN
]
=
{
"淡泊"
,
"明志"
};
char
target
[
WORDS_NUM
][
STR_LEN
]
=
{
"宁静"
,
"致远"
};
const
char
sentence_before
[
STR_LEN
];
const
char
sentence_after
[
STR_LEN
];
for
(
i
=
0
;
i
<
SENT_LEN
;
++
i
)
{
strcat
(
sentence_before
,
words
[
i
]);
for
(
j
=
0
;
j
<
WORDS_NUM
;
++
j
)
if
(
strcmp
(
words
[
i
],
source
[
j
])
==
0
)
strcpy
(
words
[
i
],
target
[
j
]);
strcat
(
sentence_after
,
words
[
i
]);
}
puts
(
"替换前:"
);
puts
(
sentence_before
);
puts
(
"替换后:"
);
puts
(
sentence_after
);
return
0
;
}
\ No newline at end of file
data/2.C语言中阶/4.字符串/2.字符串函数/string_func.json
0 → 100644
浏览文件 @
6ff49511
{
"type"
:
"code_options"
,
"author"
:
"卢昕"
,
"source"
:
"string_func.md"
,
"exercise_id"
:
"20a63ce313e241a49b6d7ccd2eb1d9e2"
}
\ No newline at end of file
data/2.C语言中阶/4.字符串/2.字符串函数/string_func.md
0 → 100644
浏览文件 @
6ff49511
# 字符串函数的使用
比较词序列,并替换其中的指定词,最后将所有词拼接形成一个新的句子。输出如下:
> 替换前:
>
> 非淡泊无以明志!
>
> 替换后:
>
> 非宁静无以致远!
>
请选出正确答案。
## 答案
```
c
#include <stdio.h>
#include <string.h>
#define SENT_LEN 5
#define WORDS_NUM 2
#define STR_LEN 101
int
main
()
{
int
i
,
j
;
char
words
[
SENT_LEN
][
STR_LEN
]
=
{
"非"
,
"淡泊"
,
"无以"
,
"明志"
,
"!"
};
char
source
[
WORDS_NUM
][
STR_LEN
]
=
{
"淡泊"
,
"明志"
};
char
target
[
WORDS_NUM
][
STR_LEN
]
=
{
"宁静"
,
"致远"
};
char
sentence_before
[
STR_LEN
];
char
sentence_after
[
STR_LEN
];
for
(
i
=
0
;
i
<
SENT_LEN
;
++
i
)
{
strcat
(
sentence_before
,
words
[
i
]);
for
(
j
=
0
;
j
<
WORDS_NUM
;
++
j
)
if
(
strcmp
(
words
[
i
],
source
[
j
])
==
0
)
strcpy
(
words
[
i
],
target
[
j
]);
strcat
(
sentence_after
,
words
[
i
]);
}
puts
(
"替换前:"
);
puts
(
sentence_before
);
puts
(
"替换后:"
);
puts
(
sentence_after
);
return
0
;
}
```
## 选项
### A
```
c
#include <stdio.h>
#include <string.h>
#define SENT_LEN 5
#define WORDS_NUM 2
#define STR_LEN 101
int
main
()
{
int
i
,
j
;
char
words
[
SENT_LEN
][
STR_LEN
]
=
{
"非"
,
"淡泊"
,
"无以"
,
"明志"
,
"!"
};
char
source
[
WORDS_NUM
][
STR_LEN
]
=
{
"淡泊"
,
"明志"
};
char
target
[
WORDS_NUM
][
STR_LEN
]
=
{
"宁静"
,
"致远"
};
char
sentence_before
[
STR_LEN
];
char
sentence_after
[
STR_LEN
];
for
(
i
=
0
;
i
<
SENT_LEN
;
++
i
)
{
strcat
(
sentence_before
,
words
[
i
]);
for
(
j
=
0
;
j
<
WORDS_NUM
;
++
j
)
if
(
strcmp
(
words
[
i
],
source
[
j
])
>=
0
)
strcpy
(
words
[
i
],
target
[
j
]);
strcat
(
sentence_after
,
words
[
i
]);
}
puts
(
"替换前:"
);
puts
(
sentence_before
);
puts
(
"替换后:"
);
puts
(
sentence_after
);
return
0
;
}
```
### B
```
c
#include <stdio.h>
#include <string.h>
#define SENT_LEN 5
#define WORDS_NUM 2
#define STR_LEN 101
int
main
()
{
int
i
,
j
;
char
*
words
[
SENT_LEN
]
=
{
"非"
,
"淡泊"
,
"无以"
,
"明志"
,
"!"
};
char
*
source
[
WORDS_NUM
]
=
{
"淡泊"
,
"明志"
};
char
*
target
[
WORDS_NUM
]
=
{
"宁静"
,
"致远"
};
char
sentence_before
[
STR_LEN
];
char
sentence_after
[
STR_LEN
];
for
(
i
=
0
;
i
<
SENT_LEN
;
++
i
)
{
strcat
(
sentence_before
,
words
[
i
]);
for
(
j
=
0
;
j
<
WORDS_NUM
;
++
j
)
if
(
strcmp
(
words
[
i
],
source
[
j
])
==
0
)
strcpy
(
words
[
i
],
target
[
j
]);
strcat
(
sentence_after
,
words
[
i
]);
}
puts
(
"替换前:"
);
puts
(
sentence_before
);
puts
(
"替换后:"
);
puts
(
sentence_after
);
return
0
;
}
```
### C
```
c
#include <stdio.h>
#include <string.h>
#define SENT_LEN 5
#define WORDS_NUM 2
#define STR_LEN 101
int
main
()
{
int
i
,
j
;
char
words
[
SENT_LEN
][
STR_LEN
]
=
{
"非"
,
"淡泊"
,
"无以"
,
"明志"
,
"!"
};
char
source
[
WORDS_NUM
][
STR_LEN
]
=
{
"淡泊"
,
"明志"
};
char
target
[
WORDS_NUM
][
STR_LEN
]
=
{
"宁静"
,
"致远"
};
const
char
sentence_before
[
STR_LEN
];
const
char
sentence_after
[
STR_LEN
];
for
(
i
=
0
;
i
<
SENT_LEN
;
++
i
)
{
strcat
(
sentence_before
,
words
[
i
]);
for
(
j
=
0
;
j
<
WORDS_NUM
;
++
j
)
if
(
strcmp
(
words
[
i
],
source
[
j
])
==
0
)
strcpy
(
words
[
i
],
target
[
j
]);
strcat
(
sentence_after
,
words
[
i
]);
}
puts
(
"替换前:"
);
puts
(
sentence_before
);
puts
(
"替换后:"
);
puts
(
sentence_after
);
return
0
;
}
```
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录