Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Level 1 finished #1

Open
wants to merge 32 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
94a14bb
Create runningLetter
xenoppy Mar 2, 2021
60d13fe
Rename runningLetter to runningLetter.cpp
xenoppy Mar 2, 2021
3c7488f
hello vscode
xenoppy Mar 3, 2021
4dc3ae2
Diophantus_completed
xenoppy Mar 3, 2021
0592d62
Diophantus_completed
xenoppy Mar 3, 2021
c3555d5
narcissus_completed
xenoppy Mar 3, 2021
9bb62ad
allPrimes_primerly_completed
xenoppy Mar 3, 2021
7f0ab39
p06_completed___p02_correct
xenoppy Mar 4, 2021
e5833d3
maze_completed
xenoppy Mar 4, 2021
4caca54
maze_completed
xenoppy Mar 4, 2021
7e7d3ec
hanoi_completed
xenoppy Mar 4, 2021
56b8ae4
Merge branch 'master' of github.com:Y-saber-icarus-black-lotus/c2021
xenoppy Mar 4, 2021
b461115
encrypt_decrvpt_approaching_completed
xenoppy Mar 6, 2021
9c5cb84
Nothing
xenoppy Mar 6, 2021
831b1e0
Maze_based_on_dfs_completed
xenoppy Mar 6, 2021
89a45c5
little_changes
xenoppy Mar 6, 2021
6fb3ce6
temporary_storage
xenoppy Mar 9, 2021
e37dfd3
Delete .gitignore
xenoppy Mar 9, 2021
b5e2825
添加了gitignore
xenoppy Mar 9, 2021
f03ae7f
Merge branch 'master' of github.com:Y-saber-icarus-black-lotus/c2021
xenoppy Mar 9, 2021
3670711
boxpusher_almost_completed
xenoppy Mar 10, 2021
7d470ee
push_box_completed
xenoppy Mar 12, 2021
931d50e
增加了一个地图文件
xenoppy Mar 12, 2021
9462256
增加了说明信息
xenoppy Mar 12, 2021
5978060
p12_warehouse_completed_including_a_examplified_file
xenoppy Mar 13, 2021
f52e334
p11_linkedList_completed
xenoppy Mar 13, 2021
d03cb10
p07_completed
xenoppy Mar 13, 2021
7eac2a3
规范了格式,level1 已完成
xenoppy Mar 13, 2021
29585be
修改了说明
xenoppy Mar 14, 2021
5fd78a5
skiplist_finished
xenoppy Apr 13, 2021
b107e3e
已修改缩进问题
xenoppy Apr 13, 2021
a465ec4
已修改
xenoppy Apr 13, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.vscode下的文件一般不用提交到github,可以看看.gitignore的用法: https://docs.github.com/cn/github/using-git/ignoring-files

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好滴,去看看

"version": "0.2.0",
"configurations": [
{//这个大括号里是我们的‘调试(Debug)’配置
"name": "Debug", // 配置名称
"type": "cppdbg", // 配置类型,cppdbg对应cpptools提供的调试功能;可以认为此处只能是cppdbg
"request": "launch", // 请求配置类型,可以为launch(启动)或attach(附加)
"program": "${fileDirname}\\bin\\${fileBasenameNoExtension}.exe", // 将要进行调试的程序的路径
"args": [], // 程序调试时传递给程序的命令行参数,这里设为空即可
"stopAtEntry": false, // 设为true时程序将暂停在程序入口处,相当于在main上打断点
"cwd": "${fileDirname}", // 调试程序时的工作目录,此处为源码文件所在目录
"environment": [], // 环境变量,这里设为空即可
// "console":"externalConsole",
"externalConsole": true, // 为true时使用单独的cmd窗口,跳出小黑框;设为false则是用vscode的内置终端,建议用内置终端
"internalConsoleOptions": "neverOpen", // 如果不设为neverOpen,调试时会跳到“调试控制台”选项卡,新手调试用不到
"MIMode": "gdb", // 指定连接的调试器,gdb是minGW中的调试程序
"miDebuggerPath": "d:\\mingw64\\bin\\gdb.exe", // 指定调试器所在路径,如果你的minGW装在别的地方,则要改成你自己的路径,注意间隔是\\
"preLaunchTask": "build" // 调试开始前执行的任务,我们在调试前要编译构建。与tasks.json的label相对应,名字要一样
}]
}
9 changes: 9 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"files.associations": {
"*.vue": "vue",
"*.wpy": "vue",
"*.wxml": "html",
"*.wxss": "css",
"iostream": "cpp"
}
}
48 changes: 48 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"version": "2.0.0",
"tasks": [
{//这个大括号里是‘构建(build)’任务
"label": "build", //任务名称,可以更改,不过不建议改
"type": "shell", //任务类型,process是vsc把预定义变量和转义解析后直接全部传给command;shell相当于先打开shell再输入命令,所以args还会经过shell再解析一遍
"command": "g++", //编译命令,这里是gcc,编译c++的话换成g++
"args": [ //方括号里是传给gcc命令的一系列参数,用于实现一些功能
"${file}", //指定要编译的是当前文件
"-o", //指定输出文件的路径和名称
"${fileDirname}\\bin\\${fileBasenameNoExtension}.exe", //承接上一步的-o,让可执行文件输出到源码文件所在的文件夹下的bin文件夹内,并且让它的名字和源码文件相同
"-g", //生成和调试有关的信息
"-Wall", // 开启额外警告
"-static-libgcc", // 静态链接libgcc
"-fexec-charset=GBK", // 生成的程序使用GBK编码,不加这一条会导致Win下输出中文乱码
"-std=c11", // 语言标准,可根据自己的需要进行修改,写c++要换成c++的语言标准,比如c++11
],
"group": { //group表示‘组’,我们可以有很多的task,然后把他们放在一个‘组’里
"kind": "build",//表示这一组任务类型是构建
"isDefault": true//表示这个任务是当前这组任务中的默认任务
},
"presentation": { //执行这个任务时的一些其他设定
"echo": true,//表示在执行任务时在终端要有输出
"reveal": "always", //执行任务时是否跳转到终端面板,可以为always,silent,never
"focus": false, //设为true后可以使执行task时焦点聚集在终端,但对编译来说,设为true没有意义,因为运行的时候才涉及到输入
"panel": "new" //每次执行这个task时都新建一个终端面板,也可以设置为shared,共用一个面板,不过那样会出现‘任务将被终端重用’的提示,比较烦人
},
"problemMatcher": "$gcc" //捕捉编译时编译器在终端里显示的报错信息,将其显示在vscode的‘问题’面板里
},
{//这个大括号里是‘运行(run)’任务,一些设置与上面的构建任务性质相同
"label": "run",
"type": "shell",
"dependsOn": "build", //任务依赖,因为要运行必须先构建,所以执行这个任务前必须先执行build任务,
"command": "${fileDirname}\\bin\\${fileBasenameNoExtension}.exe", //执行exe文件,只需要指定这个exe文件在哪里就好
"group": {
"kind": "test", //这一组是‘测试’组,将run任务放在test组里方便我们用快捷键执行
"isDefault": true
},
"presentation": {
"echo": true,
"reveal": "always",
"focus": true, //这个就设置为true了,运行任务后将焦点聚集到终端,方便进行输入
"panel": "new"
}
}

]
}
25 changes: 25 additions & 0 deletions level1/p01_runningLetter/runningLetter.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#define WIDTH 60
#include<iostream>
#include<string>
#include<Windows.h>
#include<stdio.h>
using namespace std;
int main() {
system("mode con cols=60 lines=1");
char c;
string s;
int n=0,x = 0;
cin >> s;
int len = s.length();
while (true) {
system("mode con cols=60 lines=1");
for (int i = 0; i < n; i++)cout << ' ';
cout << s;
Sleep(50);
system("cls");
x = (x + 1) % (2*(WIDTH-len));
n = (WIDTH-len-abs(x-WIDTH+len));

}
return 0;
}
23 changes: 23 additions & 0 deletions level1/p02_isPrime/source.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#define WIDTH 60
#include<iostream>
#include<string>
#include<Windows.h>
#include<math.h>
#include<stdio.h>
using namespace std;
bool judge(int n) {
bool ex = true;
if (n < 2)return false;
for (int i = 2; i <= sqrt(n); i++) {
if (n % i == 0) ex = false;
}
return ex;
}
int main() {
int x;
cin >> x;
if (judge(x))cout << "yes";
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1)if语句的条件判断,和执行分支语句,最好分行写,这样单步跟踪和断点调试的时候更方便
2)Google的编程规范中,分支语句即使只有一行,也要求用大括号抱起来,可以减少一些意外的错误
像这样:

if (judge(x)) {
      cout << "yes";
}

else cout << "no"<<endl;
system("pause");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

缩进不对,可以用IDE的自动format处理一下,vs、clion等IDE都有的

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

学到了!!!

return 0;
}