-
Notifications
You must be signed in to change notification settings - Fork 78
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
莫凯恩 #53
Open
KenNN99
wants to merge
11
commits into
luckymark:master
Choose a base branch
from
KenNN99: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
莫凯恩 #53
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
d9a2fa3
2/27 20:53
KenNN99 01e8d71
2/27 21:05
KenNN99 5fbdb2a
2/27 21:05
KenNN99 2b6d759
Update _isPrime.cpp
KenNN99 551663c
2/28 17:10
KenNN99 62c145b
Merge branch 'master' of https://github.com/KenNN99/c2019
KenNN99 afc0199
2/28 22:35
KenNN99 9dd5bff
19/3/5 21:35
KenNN99 0e27137
Update p05_allPrimes.cpp
KenNN99 489a4ea
p06-p08
KenNN99 a668b7a
correct p08. push p09-p12
KenNN99 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,38 @@ | ||
#include<stdio.h> | ||
#include<stdlib.h> | ||
#include<windows.h> | ||
#include<time.h> | ||
|
||
#define WIDE 80 | ||
#define SLEEP 5 | ||
|
||
void Run(int i); | ||
|
||
int main() | ||
{ | ||
system("mode con cols=80 lines=30"); | ||
int i; | ||
while(true) | ||
{ | ||
for (i = 1; i < WIDE; i++) | ||
{ | ||
Run(i); | ||
} | ||
for (i; i >= 0; i--) | ||
{ | ||
Run(i); | ||
} | ||
} | ||
return 0; | ||
} | ||
|
||
void Run(int i) | ||
{ | ||
for (int j = 0; j < i; j++) | ||
{ | ||
printf(" "); | ||
} | ||
printf("R"); | ||
Sleep(SLEEP); | ||
system("cls"); | ||
} |
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,35 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
void NotPrime(); | ||
|
||
int main() | ||
{ | ||
int i; | ||
scanf("%d", &i); | ||
if (i == 1) | ||
{ | ||
NotPrime(); | ||
} | ||
for (int n = 2; n*n <= i; n++) | ||
{ | ||
if (i%n == 0) | ||
{ | ||
NotPrime(); | ||
return 0; | ||
} | ||
} | ||
printf("This is a Prime."); | ||
system("pause"); | ||
return 0; | ||
} | ||
|
||
void NotPrime() | ||
{ | ||
printf("This is not a Prime!!!"); | ||
system("pause"); | ||
<<<<<<< HEAD | ||
} | ||
======= | ||
} | ||
>>>>>>> 2b6d759c8e10cfe17d315e90703734d5f6ddb2ff |
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,25 @@ | ||
#include<stdio.h> | ||
#include<stdlib.h> | ||
|
||
double Form(double x); | ||
|
||
int main() | ||
{ | ||
double x = 10; | ||
while (true) | ||
{ | ||
if (Form(x) == x) | ||
{ | ||
printf("Diophantus is %d years old when his son died.", (int)x-4); | ||
system("pause"); | ||
return 0; | ||
} | ||
x++; | ||
} | ||
} | ||
|
||
double Form(double x) | ||
{ | ||
double y = x / 6 + x / 12 + x / 7 + 5 + x / 2 + 4; | ||
return y; | ||
} |
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,32 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
int Just(int x, int y, int z); | ||
|
||
int main() | ||
{ | ||
int i, j, k; | ||
for (i = 1; i <= 9; i++) | ||
{ | ||
for (j = 0; j <= 9; j++) | ||
{ | ||
for (k = 0; k <= 9; k++) | ||
{ | ||
if (Just(i, j, k) == i * 100 + j * 10 + k) | ||
{ | ||
printf("%d ", i * 100 + j * 10 + k); | ||
} | ||
else if (i == 9 && j == 9 && k == 9) | ||
{ | ||
system("pause"); | ||
return 0; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
int Just(int x, int y, int z) | ||
{ | ||
return x * x*x + y * y*y + z * z*z; | ||
} |
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,37 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <time.h> | ||
|
||
int main() | ||
{ | ||
clock_t start, end; | ||
start = clock(); | ||
bool Prime[1001]; | ||
int i; | ||
for (i = 1; i <= 1000; i++) | ||
{ | ||
Prime[i] = true; | ||
} | ||
for (i = 2; i*i <= 1000; i++) | ||
{ | ||
if (Prime[i]) | ||
{ | ||
for (int j = 2; j*i <= 1000; j++) | ||
{ | ||
Prime[j*i] = false; | ||
} | ||
} | ||
} | ||
for (i = 2; i <= 1000; i++) | ||
{ | ||
if (Prime[i]) | ||
{ | ||
printf("%d\n", i); | ||
} | ||
} | ||
end = clock(); | ||
double duration = (double)(end - start) / CLOCKS_PER_SEC * 1000; | ||
printf("Used %f ms", duration); | ||
system("pause"); | ||
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,59 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
|
||
bool Pri[101]; | ||
|
||
void FindPrime(void); | ||
|
||
int main() | ||
{ | ||
int n, i, j; | ||
bool done; | ||
FindPrime(); | ||
for (n = 4; n <= 100; n + 2) | ||
{ | ||
done = false; | ||
for (i = 2; i <= n / 2; i++) | ||
{ | ||
if (Pri[i]) | ||
{ | ||
for (j = n - 2; j >= n / 2; j--) | ||
{ | ||
if (Pri[j]) | ||
{ | ||
if (i + j == n) | ||
{ | ||
printf("%d = %d + %d\n", n, i, j); | ||
done = true; | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
if (done) | ||
{ | ||
n = n + 2; | ||
break; | ||
} | ||
} | ||
} | ||
system("pause"); | ||
return 0; | ||
} | ||
|
||
void FindPrime(void) | ||
{ | ||
int i; | ||
memset(Pri, 1, sizeof(bool) * 101); | ||
for (i = 2; i*i <= 100; i++) | ||
{ | ||
if (Pri[i]) | ||
{ | ||
for (int j = 2; i*j <= 100; j++) | ||
{ | ||
Pri[i*j] = false; | ||
} | ||
} | ||
} | ||
} |
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,58 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
#include <time.h> | ||
|
||
#define SEED 300 | ||
|
||
int Encrypt(char *a); | ||
|
||
void Decrypt(int *b, int x); | ||
|
||
char a[128]; | ||
|
||
int b[128]; | ||
|
||
char c[128]; | ||
|
||
int main() | ||
{ | ||
fgets(a, 128, stdin); | ||
int seed = Encrypt(a); | ||
printf("After encrypting:"); | ||
int len = strlen(a); | ||
int i; | ||
for (i = 0; i < len; i++) | ||
{ | ||
printf("%d ", b[i]); | ||
} | ||
printf("\n"); | ||
Decrypt(b, seed); | ||
printf("Now we decrypt it: %s\n", c); | ||
system("pause"); | ||
return 0; | ||
} | ||
|
||
int Encrypt(char *a) | ||
{ | ||
int len = strlen(a) - 1; | ||
srand(time(NULL)); | ||
int seed = rand(); | ||
int i = 0; | ||
for (i = 0; i < len; i++) | ||
{ | ||
b[i] = a[i] * (i + 1)*(seed % SEED); | ||
} | ||
return seed; | ||
} | ||
|
||
void Decrypt(int *b, int x) | ||
{ | ||
int len = strlen(a) - 1; | ||
int i; | ||
for (i = 0; i < len; i++) | ||
{ | ||
c[i] = b[i] / (i + 1) / (x % SEED); | ||
} | ||
c[len + 1] = '\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,32 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
char A = 'A'; | ||
char B = 'B'; | ||
char C = 'C'; | ||
|
||
void Hanio(int n, char A, char B, char C); | ||
|
||
|
||
int main() | ||
{ | ||
int n; | ||
scanf("%d", &n); | ||
Hanio(n, A, B, C); | ||
system("pause"); | ||
return 0; | ||
} | ||
|
||
void Hanio(int n, char A, char B, char C) | ||
{ | ||
if (n == 1) | ||
{ | ||
printf("No.%d %c -> %c\n", n, A, C); | ||
} | ||
else | ||
{ | ||
Hanio(n - 1, A, C, B); | ||
printf("No.%d %c -> %c\n", n, A, C); | ||
Hanio(n - 1, B, A, 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,15 @@ | ||
###O############# | ||
# # # | ||
# ##### # ##### # | ||
# # # # | ||
# # ########### # | ||
# # # # # # | ||
# # # ##### # # | ||
### # # ##### | ||
# # # ####### # | ||
# # # # D | ||
# ##### ##### # # | ||
# # # # | ||
# ############# # | ||
# # | ||
################# |
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.
这里遇到了git conflict,可以在网上搜索下解决的方法;git教程里也有介绍