-
Notifications
You must be signed in to change notification settings - Fork 33
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
作业 #15
Open
Hepper123
wants to merge
26
commits into
luckymark:master
Choose a base branch
from
Hepper123:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
作业 #15
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
99bdb64
菜死了
Hepper123 8a2db4d
菜死了
Hepper123 5673898
c
Hepper123 03705b5
c
Hepper123 31de5e3
c
Hepper123 3cc3560
c
Hepper123 869e547
c
Hepper123 46ae883
c
Hepper123 77dd71d
c
Hepper123 c2ce2d5
c
Hepper123 61021ac
C
Hepper123 5e99c36
C
Hepper123 9c0b542
Update 迷宫.cpp
Hepper123 0915592
c
Hepper123 4245937
Merge branch 'master' of https://github.com/Hepper123/c2021
Hepper123 8cfe063
Update isPrime.cpp
Hepper123 ace955c
c
Hepper123 d5f48ee
Merge branch 'master' of https://github.com/Hepper123/c2021
Hepper123 3f57ebc
Update 迷宫.cpp
Hepper123 361366c
C
Hepper123 e7c9ae4
c
Hepper123 a943c66
c
Hepper123 efc6810
C
Hepper123 8bd3f79
C
Hepper123 afacf9c
c
Hepper123 cf5694a
c
Hepper123 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#include <stdio.h> | ||
#include <windows.h> | ||
|
||
int GetWidth() | ||
{ | ||
CONSOLE_SCREEN_BUFFER_INFO scr; | ||
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE); | ||
GetConsoleScreenBufferInfo(hOut, &scr); | ||
return scr.dwMaximumWindowSize.X; | ||
} | ||
|
||
int main() | ||
{ | ||
int i = 0, width = GetWidth(); | ||
while (1) | ||
{ | ||
while (i <= width-2) | ||
{ | ||
for (int j = 0; j < i; ++j) | ||
{ | ||
printf(" "); | ||
} | ||
printf("p"); | ||
Sleep(20); | ||
system("cls"); | ||
++i; | ||
} | ||
while (i >= 0) | ||
{ | ||
for (int j = 0; j < i; ++j) | ||
{ | ||
printf(" "); | ||
} | ||
printf("p"); | ||
Sleep(20); | ||
system("cls"); | ||
--i; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#include <stdio.h> | ||
|
||
bool isPrime(int num) | ||
{ | ||
if(num==1) | ||
{ | ||
return false; | ||
} | ||
for(int i =2;i*i<=num;i++) | ||
{ | ||
if(num%i==0)return false; | ||
} | ||
return true; | ||
} | ||
|
||
int main() | ||
{ | ||
int n = 0; | ||
scanf("%d", &n); | ||
if (isPrime(n)) | ||
{ | ||
printf("%d是素数", n); | ||
} | ||
else | ||
{ | ||
printf("%d不是素数", n); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include<stdio.h> | ||
|
||
int main() | ||
{ | ||
float Diophantus_age = 1; | ||
for (Diophantus_age = 1; 1; Diophantus_age++) | ||
{ | ||
|
||
if (Diophantus_age / 12 + Diophantus_age / 6 + Diophantus_age / 7 + 5 + Diophantus_age / 2 + 4 == Diophantus_age) | ||
{ | ||
break; | ||
} | ||
} | ||
printf("%d", (int)Diophantus_age-4); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,6 @@ | |
|
||
儿子比父亲先死四年, | ||
|
||
年级是他的一半。 | ||
年纪是他的一半。 | ||
|
||
问儿子死时丢番图多大? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include<stdio.h> | ||
|
||
int main() | ||
{ | ||
for (int i = 1; i < 10; i++) | ||
{ | ||
for (int j = 0; j < 10; j++) | ||
{ | ||
for (int k = 0; k < 10; k++) | ||
{ | ||
if (i * i * i + j * j * j + k * k * k == 100 * i + 10 * j + k) | ||
{ | ||
printf("%d\n", 100 * i + 10 * j + k); | ||
} | ||
} | ||
} | ||
} | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include <stdio.h> | ||
#include <time.h> | ||
|
||
int main() | ||
{ | ||
int i = 2; | ||
int IsPrime = 1; | ||
clock_t start, finish; | ||
double Total_time; | ||
start = clock(); | ||
for (i = 2; i <= 1000; i++) | ||
{ | ||
IsPrime = 1; | ||
for (int j = 2; j <= i / 2; j++) | ||
{ | ||
if (i % j == 0) | ||
{ | ||
IsPrime = 0; | ||
break; | ||
} | ||
} | ||
if (IsPrime == 1) | ||
{ | ||
printf("%d\n", i); | ||
} | ||
} | ||
finish = clock(); | ||
Total_time = (double)(finish - start) / CLOCKS_PER_SEC; | ||
printf("%f seconds\n", Total_time); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#include<stdio.h> | ||
|
||
int main() | ||
{ | ||
int i = 2; | ||
int IsPrime = 1; | ||
int a[50] = { 0 }; | ||
int k = 0; | ||
for (i = 2; i <= 100; i++) | ||
{ | ||
IsPrime = 1; | ||
for (int j = 2; j <= i / 2; j++) | ||
{ | ||
if (i % j == 0) | ||
{ | ||
IsPrime = 0; | ||
break; | ||
} | ||
} | ||
if (IsPrime == 1) | ||
{ | ||
a[k] = i; | ||
k++; | ||
} | ||
} | ||
int sum = 0; | ||
int h = 4; | ||
for (h = 4; h <= 100; h = h + 2) | ||
{ | ||
int s = 1; | ||
for (int x = 0; x < k; x++) | ||
{ | ||
for (int y = 0; y <= x; y++) | ||
{ | ||
if (a[x] + a[y] == h) | ||
{ | ||
s = 0; | ||
break; | ||
} | ||
} | ||
if (s == 0) | ||
{ | ||
break; | ||
} | ||
} | ||
if (s == 0) | ||
{ | ||
sum++; | ||
} | ||
} | ||
if (sum == 49) | ||
{ | ||
printf("��°ͺղ�����100��Χ������ȷ��"); | ||
} | ||
else | ||
{ | ||
printf("��°ͺղ�����100��Χ�ڲ�����ȷ��"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#include <stdio.h> | ||
#include <string.h> | ||
#include <iostream> | ||
|
||
void encrypt(char* source, char* encrypted) | ||
{ | ||
while (*source != '\0') | ||
{ | ||
*encrypted = 158 - *source; | ||
source++; | ||
encrypted++; | ||
} | ||
} | ||
|
||
void decrypt(char* encrypted, char* source) | ||
{ | ||
while (*encrypted != '\0') | ||
{ | ||
*source = 158 - *encrypted; | ||
source++; | ||
encrypted++; | ||
} | ||
} | ||
|
||
int main() | ||
{ | ||
printf("��������Ҫ�����ַ����ij��ȣ�"); | ||
int n = 0; | ||
std::cin >> n; | ||
char* a = new char[n + 1](); | ||
char* b = new char[n + 1](); | ||
scanf("%s", a); | ||
encrypt(a, b); | ||
printf("���ܺ���ַ���Ϊ��"); | ||
printf("%s\n", b); | ||
printf("��������Ҫ���ܵ��ַ����ij��ȣ�"); | ||
int s = 0; | ||
scanf("%d", &s); | ||
char* c = new char[n + 1](); | ||
char* d = new char[n + 1](); | ||
printf("��Ҫ���ܵ��ַ���Ϊ��"); | ||
scanf("%s", c); | ||
decrypt(c, d); | ||
printf("���ܺ���ַ���Ϊ��"); | ||
printf("%s", d); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#include<iostream> | ||
|
||
void hanoi(int n, char a, char b, char c) | ||
{ | ||
if (n == 1) | ||
{ | ||
printf("��Բ��%d��%c�Ƶ�%c", n, a, c); | ||
} | ||
else | ||
{ | ||
hanoi(n - 1, a, c, b); | ||
printf("��Բ��%d��%c�Ƶ�%c", n, a, c); | ||
hanoi(n - 1, b, a, c); | ||
} | ||
} | ||
int main() | ||
{ | ||
char A = 'A'; | ||
char B = 'B'; | ||
char C = 'C'; | ||
hanoi(64, A, B, C); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
#include<iostream> | ||
#include<conio.h> | ||
#include<windows.h> | ||
using namespace std; | ||
HANDLE hOut; | ||
|
||
char cursorCharRead() | ||
{ | ||
char buf[BUFSIZ]; | ||
CONSOLE_SCREEN_BUFFER_INFO csbiInfo; | ||
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); | ||
GetConsoleScreenBufferInfo(hConsole, &csbiInfo); | ||
COORD pos = csbiInfo.dwCursorPosition; | ||
TCHAR strFromConsole[1]; | ||
DWORD dwChars; | ||
ReadConsoleOutputCharacter(hConsole,strFromConsole,1,pos,&dwChars); | ||
char c = strFromConsole[0]; | ||
return c; | ||
} | ||
|
||
int main() | ||
{ | ||
printf("******************* *********************\n"); | ||
printf("* * * * * * * *\n"); | ||
printf("* * ******* * * * * ***** * * ***** * * *\n"); | ||
printf("* * * * * * * * * * * * *\n"); | ||
printf("******* ***** * * ***** *** ***** * * * *\n"); | ||
printf("* * * * * * * * * * *\n"); | ||
printf("* * * *** * *** *** * *** ***** ***** * *\n"); | ||
printf("* * * * * * * * * *\n"); | ||
printf("* * *** ************* * ***** ***** *** *\n"); | ||
printf("* * * * * * * * * * * * * *\n"); | ||
printf("* *** ******* * * * ***** * * * * *** * *\n"); | ||
printf("* * * * * * * * * * * *\n"); | ||
printf("* * ********* ***** * * *** * * ***** * *\n"); | ||
printf("* * * * * * * * * * * * * *\n"); | ||
printf("* * * * * *** * * *** * * ***** * * *****\n"); | ||
printf("* * * * * * * * * * * * * *\n"); | ||
printf("* ***** * * *** *** *** ***** * * ***** *\n"); | ||
printf("* * * * * * * * * * *\n"); | ||
printf("* ******* *** *** *** * *** *** ***** * *\n"); | ||
printf("* * * * * * * * * * * * *\n"); | ||
printf("* * *** * * *** *** ***** *** * *** *** *\n"); | ||
printf("* * * * * * * * * * *\n"); | ||
printf("* * * * ***** * ***** * ********* * *****\n"); | ||
printf("* * * * * * * * *\n"); | ||
printf("* * ******* ***** * *** * *** *** *** * *\n"); | ||
printf("* * * * * * * * * * * *\n"); | ||
printf("* ***** *** * ******* ***** *** * * *****\n"); | ||
printf("* * * * * * * * * *\n"); | ||
printf("********* ******* * ***** * * * *** *** *\n"); | ||
printf("* * * * * * * * * * * *\n"); | ||
printf("***** * *** *** *** * * ******* * *** * *\n"); | ||
printf("* * * * * * * * * * * *\n"); | ||
printf("* * *** * *** ***** ***** * * * * * * ***\n"); | ||
printf("* * * * * * * * * * * *\n"); | ||
printf("* *** ***** * * * * * * *** *********** *\n"); | ||
printf("* * * * * * * * * * * *\n"); | ||
printf("******* * * ***** ******* *** ******* * *\n"); | ||
printf("* * * * * * * * * *\n"); | ||
printf("* ***** *** * * ***** * *** *** * *** * *\n"); | ||
printf("* * * * * * * * *\n"); | ||
printf("********************* *******************\n"); | ||
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE); | ||
COORD w = { 21, 40 }; | ||
SetConsoleCursorPosition(hOut, w); | ||
while (w.X != 19 || w.Y != 0) | ||
{ | ||
int ch1 = 0, ch2 = 0; | ||
int t = 0; | ||
if (ch1 = getch()) | ||
{ | ||
ch2 = getch(); | ||
switch (ch2) | ||
{ | ||
case 72:w.Y--; t = 1; break; | ||
case 80:w.Y++; t = 2; break; | ||
case 75:w.X--; t = 3; break; | ||
case 77:w.X++; t = 4; break; | ||
} | ||
} | ||
SetConsoleCursorPosition(hOut, w); | ||
if (cursorCharRead() == '*') | ||
{ | ||
switch (t) | ||
{ | ||
case 1:w.Y++; break; | ||
case 2:w.Y--; break; | ||
case 3:w.X++; break; | ||
case 4:w.X--; break; | ||
} | ||
} | ||
SetConsoleCursorPosition(hOut, w); | ||
} | ||
w.X = 0; | ||
w.Y = 41; | ||
SetConsoleCursorPosition(hOut, w); | ||
printf("恭喜过关!"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
0 0 3 3 3 3 0 0 | ||
0 0 3 2 2 3 0 0 | ||
0 3 3 0 2 3 3 0 | ||
0 3 0 0 4 2 3 0 | ||
3 3 0 4 0 0 3 3 | ||
3 0 0 3 4 4 0 3 | ||
3 0 0 1 0 0 0 3 | ||
3 3 3 3 3 3 3 3 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
重复的味道,试着消除吧