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 28 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
54 changes: 0 additions & 54 deletions .gitignore

This file was deleted.

30 changes: 29 additions & 1 deletion C语言学习笔记.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,32 @@

# 记录你学习过程中的所见所思!酸甜苦辣!

# 看什么看! 赶紧填坑啊!
# 看什么看! 赶紧填坑啊!
git{
有3级:
1.working folder 工作区
2.stage
3.版本管理仓库
git add添加的是变化
git commit 是将stage中的变化增加到仓库
git push 将仓库推到远端
git clone和git pull:https://www.jianshu.com/p/c6a0397ec6f5
}
cin执行被跳过:https://blog.csdn.net/weixin_48066554/article/details/106825215
console控制台相关:https://www.cnblogs.com/flowingwind/p/8159035.html
{
注意算术移位和逻辑移位
有关补码、原码、反码:https://www.cnblogs.com/dongao/p/11538424.html

}

记录一些已写的函数:
需要头文件<string>
其中s为打开文件的类型
FILE *getfile(string s)
{
cout << "please put in the path" << endl;
string path;
cin >> path;
return fopen(path.c_str(), s.c_str());
}
29 changes: 29 additions & 0 deletions level1/p01_runningLetter/runningLetter.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#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;
}
35 changes: 35 additions & 0 deletions level1/p02_isPrime/source.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#define WIDTH 60
#include <iostream>
#include <string>
#include <Windows.h>
#include <math.h>
#include <stdio.h>
using namespace std;
bool judge(int n)
{
if (n < 2)
{
return false;
}
for (int i = 2; i <= sqrt(n); i++)
{
if (n % i == 0)
return false;
}
return false;
}
int main()
{
int x;
cin >> x;
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;
}
9 changes: 9 additions & 0 deletions level1/p03_Diophantus/source.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include<iostream>
#include<math.h>
#include<stdio.h>
using namespace std;
int main() {
cout <<(5+4)/(1-1.0/6-1.0/12-1.0/7-1.0/2)-4 <<endl;
system("pause");
return 0;
}
22 changes: 22 additions & 0 deletions level1/p04_ narcissus/source.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <iostream>
#include <math.h>
#include <stdio.h>
using namespace std;
bool judge(int n)
{
if (pow(n / 100, 3) + pow(n / 10 % 10, 3) + pow(n % 10, 3) == n)
{
return true;
}
return false;
}
int main()
{
for (int i = 100; i <= 999; i++)
{
if (judge(i))
cout << i << endl;
}
system("pause");
return 0;
}
42 changes: 42 additions & 0 deletions level1/p05_allPrimes/source.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <Windows.h>
#include <time.h>
using namespace std;
int primes[170], pn = 1;
bool judge(int n)
{
if (n < 2)
return false;
for (int i = 0; i < pn; i++)
{
if (n % primes[i] == 0)
return false;
if (primes[i] > sqrt(n))
return true;
}
return false;
}
int main()
{
primes[0] = 2;
DWORD start_time = GetTickCount();
int start_clock = clock();
cout << 2 << endl;
for (int i = 3; i <= 1000; i = i + 2)
{
if (judge(i))
{
cout << i << endl;
primes[pn] = i;
pn = pn + 1;
}
}
DWORD end_time = GetTickCount();
int end_clock = clock();
cout << "time:" << end_time - start_time << endl;
cout << "clock:" << end_clock - start_clock << endl;
system("pause");
return 0;
}
35 changes: 35 additions & 0 deletions level1/p06_Goldbach/source.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <Windows.h>
#include <time.h>
using namespace std;
bool judge(int n)
{
if (n < 2)
{
return false;
}
for (int i = 2; i <= sqrt(n); i++)
{
if (n % i == 0)
{
return false;
}
}
return true;
}
int main()
{
for (int i = 4; i <= 100; i = i + 2)
{
for (int j = 2; j < 100; j++)
if (judge(j) && judge(i - j))
{
cout << i << "=" << j << "+" << i - j << endl;
break;
}
}
system("pause");
return 0;
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion level1/p07_encrypt_decrypt/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 功能要求:

1. 分别编写“加密”、“解密”函数,输入为任意长度的字符串
1. 分别编写“加密”、“解密”函数,输入为任意长度的字符串


加密方法:将字符的ascii码化为二进制,并补上一位随机数形成一个八位二进制数,再将其两两分组,再进行跨组排序,组合三组并插上一个随机位

79 changes: 79 additions & 0 deletions level1/p07_encrypt_decrypt/source.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <Windows.h>
#include <string>
#include <time.h>
using namespace std;
int group[1000][4];
int input[1000][3];
void decrypt()
{
string s;
cout << "please put in the contents you want to decrypt" << endl;
cin >> s;
unsigned j = 0;
unsigned len = s.length();
for (unsigned i = 0; i < len; i = i + 3)
{
char a = ((s[i] - 97) / 8) * 8 + ((s[i + 1] - 97) / 8) * 2 + ((s[i + 2] - 97) / 8) / 2 + 97;
cout << a;
}

cout << endl;
}
void encrypt()
{
srand(time(0));
string s;
cout << "please put in the contents you want to encrypt" << endl;
cin >> s;
unsigned len = s.length();
for (unsigned i = 0; i < len; i++)
{
srand((unsigned)time(NULL));
input[i][0] = (s[i] - 97) / 8;
input[i][1] = ((s[i] - 97) / 2) % 4;
input[i][2] = ((s[i] - 97) % 2) * 2 + rand() % 2;
}
for (unsigned i = 0; i < len; i = i + 1)
{
srand((unsigned)time(NULL));
char a = input[i][0] * 8 + input[(i + 1) % len][0] * 2 + rand() % 2 + 97;
Copy link
Owner

Choose a reason for hiding this comment

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

重复的味道

char b = input[i][1] * 8 + input[(i + 1) % len][1] * 2 + rand() % 2 + 97;
char c = input[i][2] * 8 + input[(i + 1) % len][2] * 2 + rand() % 2 + 97;

cout << a;
cout << b;
cout << c;
}
cout << endl;
system("pause");
}
int main()
{
cout << "encrypt or decrypt?" << endl
<< "please put in E or D to choose the mode or put in e to exit the program" << endl;
char c;
cin >> c;
switch (c)
{
case 'E':
{
encrypt();
break;
}
case 'D':
{
decrypt();
break;
}
case 'e':
break;
default:
cout << "??????????????????????" << endl
<< "Please check!";
}
system("pause");
return 0;
}
26 changes: 26 additions & 0 deletions level1/p08_hanoi/source.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <Windows.h>
#include <time.h>
using namespace std;
int saves[10000];
int hanoi(int n)
{
if (saves[n] == 0)
{
Copy link
Owner

Choose a reason for hiding this comment

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

啊,是我没写清楚需求,要求打印出移动的步骤,例如:
A->C
A->B
B->C
...

saves[n] = 2 * hanoi(n - 1) + 1;
return 2 * hanoi(n - 1) + 1;
}
else
return saves[n];
}
int main()
{
saves[1] = 1;
int n;
cin >> n;
cout << hanoi(n) << endl;
system("pause");
return 0;
}
Loading