From c112cd200a180dc510d9de942b338bafe9c32ff6 Mon Sep 17 00:00:00 2001 From: HelixCopex Date: Thu, 17 Apr 2025 19:09:08 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BC=96=E5=86=99=E5=88=B0=E7=AC=AC=E4=BA=8C?= =?UTF-8?q?=E7=AB=A0=E5=BC=80=E5=A4=B4=EF=BC=8C=E5=8A=A0=E4=B8=8A=E5=92=8C?= =?UTF-8?q?=E4=B8=80=E4=B8=AA=E7=AC=94=E8=AE=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/tasks.json | 28 ++++++++++++++++++++++++ Chapter_1/1_1.c | 12 ++++++++++ Chapter_1/1_2.c | 7 ++++++ Chapter_2/2_1_first.c | 12 ++++++++++ notes/第一个程序_输入_输出_和逻辑运算.md | 17 ++++++++++++++ 5 files changed, 76 insertions(+) create mode 100644 .vscode/tasks.json create mode 100644 Chapter_1/1_1.c create mode 100644 Chapter_1/1_2.c create mode 100644 Chapter_2/2_1_first.c create mode 100644 notes/第一个程序_输入_输出_和逻辑运算.md diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..d891585 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,28 @@ +{ + "tasks": [ + { + "type": "cppbuild", + "label": "C/C++: gcc.exe 生成活动文件", + "command": "C:\\msys64\\ucrt64\\bin\\gcc.exe", + "args": [ + "-fdiagnostics-color=always", + "-g", + "${file}", + "-o", + "${fileDirname}\\${fileBasenameNoExtension}.exe" + ], + "options": { + "cwd": "${fileDirname}" + }, + "problemMatcher": [ + "$gcc" + ], + "group": { + "kind": "build", + "isDefault": true + }, + "detail": "调试器生成的任务。" + } + ], + "version": "2.0.0" +} \ No newline at end of file diff --git a/Chapter_1/1_1.c b/Chapter_1/1_1.c new file mode 100644 index 0000000..fbce18e --- /dev/null +++ b/Chapter_1/1_1.c @@ -0,0 +1,12 @@ +#include + +int main(void) +{ + int dogs; + + printf("How many dogs do you have?\n"); + scanf("%d", &dogs); + printf("So you have %d dog(s)!\n", dogs); + + return 0; +} \ No newline at end of file diff --git a/Chapter_1/1_2.c b/Chapter_1/1_2.c new file mode 100644 index 0000000..46e8ac9 --- /dev/null +++ b/Chapter_1/1_2.c @@ -0,0 +1,7 @@ +#include +int main(void) +{ + printf("Concrete contain gravel and cement.\n"); + + return 0; +} \ No newline at end of file diff --git a/Chapter_2/2_1_first.c b/Chapter_2/2_1_first.c new file mode 100644 index 0000000..42b715a --- /dev/null +++ b/Chapter_2/2_1_first.c @@ -0,0 +1,12 @@ +#include +int main(void) /* 一个简单的 C 程序 */ +{ + int num; //定义一个整型变量 num + num = 1; //赋值为1 + + printf("I am a simple"); //使用printf()函数 + printf("computer.\n"); + printf("My favorite number is %d because it is first.\n", num); + + return 0; +} \ No newline at end of file diff --git a/notes/第一个程序_输入_输出_和逻辑运算.md b/notes/第一个程序_输入_输出_和逻辑运算.md new file mode 100644 index 0000000..821ece9 --- /dev/null +++ b/notes/第一个程序_输入_输出_和逻辑运算.md @@ -0,0 +1,17 @@ +# C Prime Plus 示例代码库 + +## 写在前面 + +这是我个人对 **C Prime Plus** 这本书中示例代码的复现和对一些习题尝试给出的解答。在学习这本教材时,如果有不懂的部分,可以在这个代码库中找到参考。 + +入门部分可以让大家快速上手 C 语言,主要使用了[这个视频](https://www.bilibili.com/video/BV1dr4y1n7vA)作为教材。相当于这个教材的文字版本,看完以后应该刚刚好够你应付第一个学期的 C 语言考试。其中有关算法的初步讲解非常到位且容易上手。 + +但是,我仅仅建议用这个视频来初步感知 C 语言是什么,以及编写 C 语言的大致路径究竟是怎么样的。在真正书写一些 C 语言程序时,开发规范一般应当遵照这本书:**C Prime Plus** + +在提升部分,主要基于 *C Prime Plus* 这本书来讲解。这本书深入浅出,事无巨细地讲解了 C 语言的程序开发、编写到运行过程中的大部分知识,如果你真的看懂了这本书,那么你在简历上写“精通 C 语言程序开发”就是完全不成问题的了。 + +我如此推崇这本书的原因是,它是由 **真正研究 C 语言,制定 C 标准的人** 写的,而不只是为了适应特定项目开发,或者教会学生怎么写一些 C 代码的人写的。 + +## 环境配置 + +所有需要教给大家的部分只有环境如何配置。现今所存的所有 C 语言教学中,环境配置五花八门,很多想要入门的同学往往都是卡在了这一步,或者被一些不当的环境配置搞得死去活来。所以现在,这份文档将教你以最新的 VSCode 一步步快速地搭建出一个顺手的开发环境。