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

顾颉 #23

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
43 changes: 43 additions & 0 deletions level1/p01_runningLetter/RunningLetter.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// RunningLetter.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

#include <stdio.h>
#include <windows.h>

int main()
{
char a;
scanf_s("%c", &a);
for (int i = 1; i <= 118; i++)
{
system("cls");
for (int j = 0; j <= i; j++)
{
printf(" ");
}
printf("%c", a);
Sleep(10);
}
for (int p = 118; p >= 1; p--)
{
system("cls");
for (int x = 0; x <= p; x++)
{
printf(" ");
}
printf("%c", a);
Sleep(10);
}
return 0;
}

// 运行程序: Ctrl + F5 或调试 >“开始执行(不调试)”菜单
// 调试程序: F5 或调试 >“开始调试”菜单

// 入门使用技巧:
// 1. 使用解决方案资源管理器窗口添加/管理文件
// 2. 使用团队资源管理器窗口连接到源代码管理
// 3. 使用输出窗口查看生成输出和其他消息
// 4. 使用错误列表窗口查看错误
// 5. 转到“项目”>“添加新项”以创建新的代码文件,或转到“项目”>“添加现有项”以将现有代码文件添加到项目
// 6. 将来,若要再次打开此项目,请转到“文件”>“打开”>“项目”并选择 .sln 文件
28 changes: 28 additions & 0 deletions level1/p03_Diophantus/Diophantus.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Diophantus.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

#include <stdio.h>

int main()
{
int x, y;
for (x = 28; x <= 120; x=x+28)
{
y=x/2;
if (x - y == x * 11 / 28 +9 )
break;
}
printf("%d", x-4);
return 0;
}

// 运行程序: Ctrl + F5 或调试 >“开始执行(不调试)”菜单
// 调试程序: F5 或调试 >“开始调试”菜单

// 入门使用技巧:
// 1. 使用解决方案资源管理器窗口添加/管理文件
// 2. 使用团队资源管理器窗口连接到源代码管理
// 3. 使用输出窗口查看生成输出和其他消息
// 4. 使用错误列表窗口查看错误
// 5. 转到“项目”>“添加新项”以创建新的代码文件,或转到“项目”>“添加现有项”以将现有代码文件添加到项目
// 6. 将来,若要再次打开此项目,请转到“文件”>“打开”>“项目”并选择 .sln 文件
27 changes: 27 additions & 0 deletions level1/p04_ narcissus/narcissus.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// narcissus.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

#include <stdio.h>
#include <math.h>

int main()
{
int x;
for (x = 100; x <= 999; x++)
{
if (x == pow(x % 10, 3) + pow(x / 10 % 10,3)+pow(x/100%10,3))
printf("%d\n",x);
}
return 0;
}

// 运行程序: Ctrl + F5 或调试 >“开始执行(不调试)”菜单
// 调试程序: F5 或调试 >“开始调试”菜单

// 入门使用技巧:
// 1. 使用解决方案资源管理器窗口添加/管理文件
// 2. 使用团队资源管理器窗口连接到源代码管理
// 3. 使用输出窗口查看生成输出和其他消息
// 4. 使用错误列表窗口查看错误
// 5. 转到“项目”>“添加新项”以创建新的代码文件,或转到“项目”>“添加现有项”以将现有代码文件添加到项目
// 6. 将来,若要再次打开此项目,请转到“文件”>“打开”>“项目”并选择 .sln 文件
37 changes: 37 additions & 0 deletions level1/p05_allPrimes/allPrimes.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// allPrimes.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

#include <stdio.h>
#include <time.h>
#include <math.h>

int main()
{
int p,x;
double a, b;
a = clock();
for (p = 2; p <= 1000; p++)
{
x = 0;
for (int i = 2; i <= sqrt(p); i++)
{
if (p % i == 0)
x++;
}
if (x == 0) printf("%d\n", p);
}
b = clock();
printf("运行时间为%.3fs", (b-a)/1000);
return 0;
}

// 运行程序: Ctrl + F5 或调试 >“开始执行(不调试)”菜单
// 调试程序: F5 或调试 >“开始调试”菜单

// 入门使用技巧:
// 1. 使用解决方案资源管理器窗口添加/管理文件
// 2. 使用团队资源管理器窗口连接到源代码管理
// 3. 使用输出窗口查看生成输出和其他消息
// 4. 使用错误列表窗口查看错误
// 5. 转到“项目”>“添加新项”以创建新的代码文件,或转到“项目”>“添加现有项”以将现有代码文件添加到项目
// 6. 将来,若要再次打开此项目,请转到“文件”>“打开”>“项目”并选择 .sln 文件
27 changes: 27 additions & 0 deletions level1/p06_Goldbach/narcissus.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// narcissus.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

#include <stdio.h>
#include <math.h>

int main()
{
int x;
for (x = 100; x <= 999; x++)
{
if (x == pow(x % 10, 3) + pow(x / 10 % 10,3)+pow(x/100%10,3))
printf("%d\n",x);
}
return 0;
}

// 运行程序: Ctrl + F5 或调试 >“开始执行(不调试)”菜单
// 调试程序: F5 或调试 >“开始调试”菜单

// 入门使用技巧:
// 1. 使用解决方案资源管理器窗口添加/管理文件
// 2. 使用团队资源管理器窗口连接到源代码管理
// 3. 使用输出窗口查看生成输出和其他消息
// 4. 使用错误列表窗口查看错误
// 5. 转到“项目”>“添加新项”以创建新的代码文件,或转到“项目”>“添加现有项”以将现有代码文件添加到项目
// 6. 将来,若要再次打开此项目,请转到“文件”>“打开”>“项目”并选择 .sln 文件
56 changes: 56 additions & 0 deletions level1/p07_encrypt_decrypt/encrypt_decrypt.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// encrypt_decrypt.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

#include <stdio.h>
#include <string.h>

int main()
{
char a[10],e[100],d[100];
gets_s(a,10);
if (strcmp(a, "encrypt") == 0)
{
printf("please input your string:\n");
gets_s(e, 100);
for (int i = 0; i <= 99; i++)
{
if ((e[i] >= 65 && e[i] <= 86) || (e[i] >= 97 && e[i] <= 118))
e[i] = e[i] + 4;
else
if ((e[i] >= 87 && e[i] <= 90) || e[i] >= 119 && e[i] <= 122)
e[i] = e[i] - 22;
}
puts(e);
}
else
{
if (strcmp(a, "decrypt") == 0)
{
printf("please input your string:\n");
gets_s(d, 100);
for (int j = 0; j <= 99; j++)
{
if ((d[j] >= 69 && d[j] <= 90) || (d[j] >= 101 && d[j] <= 122))
d[j] = d[j] - 4;
else
if ((d[j] >= 65 && d[j] <= 68) || d[j] >= 97 && d[j] <= 100)
d[j] = d[j] + 22;
}
puts(d);
}
else
printf("error");
}
return 0;
}

// 运行程序: Ctrl + F5 或调试 >“开始执行(不调试)”菜单
// 调试程序: F5 或调试 >“开始调试”菜单

// 入门使用技巧:
// 1. 使用解决方案资源管理器窗口添加/管理文件
// 2. 使用团队资源管理器窗口连接到源代码管理
// 3. 使用输出窗口查看生成输出和其他消息
// 4. 使用错误列表窗口查看错误
// 5. 转到“项目”>“添加新项”以创建新的代码文件,或转到“项目”>“添加现有项”以将现有代码文件添加到项目
// 6. 将来,若要再次打开此项目,请转到“文件”>“打开”>“项目”并选择 .sln 文件
30 changes: 30 additions & 0 deletions level1/p08_hanoi/hanoi.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include <stdio.h>

void hanoi(int n, char a, char b, char c);
void move(char from, char to);
int main()
{
int n;
scanf_s("%d", &n);
hanoi(n, 'A', 'B', 'C');
return 0;
}
void hanoi(int n, char a, char b, char c)
{
if (n == 1)
{
move(a, c);
}
else
{
hanoi(n - 1, a, c, b);
move(a, c);
hanoi(n - 1, b, a, c);
return;
}
}
void move(char from, char to)
{
printf("%c->%c\n", from, to);
return;
}
105 changes: 105 additions & 0 deletions level1/p09_maze/maze.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@


#include <stdio.h>
#include <conio.h>
#include <stdlib.h>


int main()
{
char maze[10][20] =
{ {'#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#'},
{'#','O','#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#',' ',' ','#',' ',' ','#'},
{'#',' ','#',' ','#','#','#','#','#','#',' ','#','#','#',' ',' ',' ',' ',' ','#'},
{'#',' ',' ',' ',' ',' ','#',' ',' ','#',' ','#',' ','#',' ','#','#','#',' ','#'},
{'#','#','#','#',' ',' ','#',' ',' ','#',' ','#',' ','#',' ','#',' ','#',' ','#'},
{'#',' ',' ',' ',' ','#','#',' ',' ','#',' ',' ',' ','#',' ','#',' ','#',' ','#'},
{'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#',' ','#'},
{'#','#','#','#',' ',' ',' ','#',' ','#','#','#','#',' ','#',' ',' ','#',' ','#'},
{'#',' ',' ',' ',' ',' ',' ','#','#',' ',' ',' ',' ',' ','#','#','#',' ',' ',' '},
{'#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#' }
};
char *p=&maze[1][1],direction;
while (maze[8][19] != 'O')
{
system("cls");
for (int i = 0; i <= 9; i++)
{
for (int j = 0; j <= 19; j++)
{
printf("%c", maze[i][j]);
}
printf("\n");
}
direction = _getch();
switch (direction)
{
case 'w':
{
if (*(p - 20) == ' ')
{
*p = ' ';
p-=20;
*p = 'O';
break;
}
else
break;
}
{

}
case 'a':
{
if (*(p - 1) == ' ')
{
*p = ' ';
p--;
*p = 'O';
break;
}
else
break;
}
case 's':
{
if (*(p + 20) == ' ')
{
*p = ' ';
p += 20;
*p = 'O';
break;
}
else
break;
}
case 'd':
{
if (*(p + 1) == ' ')
{
*p = ' ';
p++;
*p = 'O';
break;
}
else
break;
}
}
}
system("cls");
for (int i = 0; i <= 9; i++)
{
for (int j = 0; j <= 19; j++)
{
printf("%c", maze[i][j]);
}
printf("\n");
}
printf("\nYou win!\n");
return 0;
}




31 changes: 31 additions & 0 deletions level1/p10_pushBoxes/pushBoxes/pushBoxes.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31105.61
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pushBoxes", "pushBoxes\pushBoxes.vcxproj", "{574A989A-A0DE-4E10-A775-F329CA583623}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{574A989A-A0DE-4E10-A775-F329CA583623}.Debug|x64.ActiveCfg = Debug|x64
{574A989A-A0DE-4E10-A775-F329CA583623}.Debug|x64.Build.0 = Debug|x64
{574A989A-A0DE-4E10-A775-F329CA583623}.Debug|x86.ActiveCfg = Debug|Win32
{574A989A-A0DE-4E10-A775-F329CA583623}.Debug|x86.Build.0 = Debug|Win32
{574A989A-A0DE-4E10-A775-F329CA583623}.Release|x64.ActiveCfg = Release|x64
{574A989A-A0DE-4E10-A775-F329CA583623}.Release|x64.Build.0 = Release|x64
{574A989A-A0DE-4E10-A775-F329CA583623}.Release|x86.ActiveCfg = Release|Win32
{574A989A-A0DE-4E10-A775-F329CA583623}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C5086666-B2B4-4D5C-94B1-455AB3488F44}
EndGlobalSection
EndGlobal
1 change: 1 addition & 0 deletions level1/p10_pushBoxes/pushBoxes/pushBoxes/map1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
### #X# # #######O OX##X OI#######O# #X# ###
1 change: 1 addition & 0 deletions level1/p10_pushBoxes/pushBoxes/pushBoxes/map2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#### #XX# ## X## # OX# ## O ### #OO ## I #########
Loading