-
Notifications
You must be signed in to change notification settings - Fork 35
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
樊捷明 cpp1~9 + 打飞机游戏 #32
Open
ffjmmm
wants to merge
11
commits into
luckymark:master
Choose a base branch
from
ffjmmm: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
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
f0d218a
完成了Level1 1~6题
58dd98a
完成Level01所有练习
3e8df18
修改了一点Bug
b4ab458
修改了格式问题
ed00895
修改了部分问题
b8d08b9
Cpp 1~6
44a1a04
完成大部分游戏内容
ffjmmm 710953f
fix bug
ffjmmm e5426ff
fix bus
ffjmmm ffdb160
将打飞机游戏加入
ffjmmm 883ca23
cpp 7~9
ffjmmm 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 |
---|---|---|
@@ -1 +1,2 @@ | ||
slides/.idea | ||
*.DS_Store |
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 <string.h> | ||
#include <unistd.h> | ||
#include <stdlib.h> | ||
#define N 20 | ||
|
||
char ch[N]; | ||
|
||
void runLetter(int n) { | ||
system("clear"); | ||
for (int i = 0; i < n; i++) { | ||
printf(" "); | ||
} | ||
puts(ch); | ||
usleep(50000); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 缩进对齐 |
||
} | ||
|
||
int checkRight(int t) { | ||
return t <= 80 - strlen(ch); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 80应该定义一个常量 |
||
} | ||
|
||
int checkLeft(int t) { | ||
return t >= 0; | ||
} | ||
|
||
int main() { | ||
printf("Input the word or letter:\n"); | ||
gets(ch); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 缩进对齐 |
||
while (1) { | ||
int t = 0; | ||
while (checkRight(t)) { | ||
runLetter(t++); | ||
} | ||
while (checkLeft(--t)) { | ||
runLetter(t); | ||
} | ||
} | ||
} |
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,18 @@ | ||
#include <stdio.h> | ||
#include <math.h> | ||
|
||
int isPrime(int n) { | ||
if (n == 1) return 0; | ||
for (int i = 2; i <= sqrt(n); i++) { | ||
if (n % i == 0) return 0; | ||
} | ||
return 1; | ||
} | ||
|
||
int main () { | ||
int n; | ||
scanf("%d",&n); | ||
if (isPrime(n)) printf("Yes!"); | ||
else printf("No!"); | ||
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,15 @@ | ||
#include <stdio.h> | ||
|
||
int check(int n) { | ||
if (n%6 != 0 || n%12 != 0 || n%7 !=0) return 0; | ||
int x = n/6 + n/12 + n/7 + 5; | ||
int ageSon = n - x - 4; | ||
return n == ageSon * 2; | ||
} | ||
|
||
int main() { | ||
for (int i = 1; i <= 1000; i++) { | ||
if (check(i)) printf("%d ",i - 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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include <stdio.h> | ||
|
||
int Power(int x) { | ||
return x*x*x; | ||
} | ||
|
||
int narcissusChange(int n) { | ||
int ans = 0; | ||
while (n) { | ||
ans += Power(n%10); | ||
n = n/10; | ||
} | ||
return ans; | ||
} | ||
|
||
int main() { | ||
for (int i = 100; i < 1000; i++) { | ||
if (i == narcissusChange(i)) printf("%d\t",i); | ||
} | ||
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,24 @@ | ||
#include <stdio.h> | ||
#include <string.h> | ||
#define N 1001 | ||
|
||
int isPrime[N]; | ||
|
||
void init() { | ||
memset(isPrime,1,sizeof(isPrime)); | ||
for (int i = 2; i < N; i++) { | ||
if (isPrime[i]) { | ||
for (int j = 2; i*j < N; j++) { | ||
isPrime[i*j] = 0; | ||
} | ||
} | ||
} | ||
} | ||
|
||
int main() { | ||
init(); | ||
for (int i = 2; i < N; i++) { | ||
if (isPrime[i]) printf("%d\t",i); | ||
} | ||
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,64 @@ | ||
#include <stdio.h> | ||
#include <math.h> | ||
#define N 101 | ||
|
||
int primes[20]; | ||
int numberOfPrimes; | ||
struct data { | ||
int a,b,c; | ||
}a[N]; | ||
|
||
int isPrime(int x) { | ||
for (int i = 2; i <= sqrt(x); i++) { | ||
if (x%i == 0) return 0; | ||
} | ||
return 1; | ||
} | ||
|
||
void init() { | ||
numberOfPrimes = 0; | ||
for (int i = 3; i < 100; i++) { | ||
if (isPrime(i)) { | ||
primes[numberOfPrimes++] = i; | ||
} | ||
} | ||
} | ||
|
||
int main() { | ||
init(); | ||
for (int i = 0; i < numberOfPrimes; i++) { | ||
for (int j = i; j < numberOfPrimes; j++) { | ||
int k = primes[i] + primes[j]; | ||
if (k > 100) { | ||
break; | ||
} | ||
a[k].a = primes[i]; | ||
a[k].b = primes[j]; | ||
} | ||
} | ||
|
||
for (int i = 0; i < numberOfPrimes; i++) { | ||
for (int j = i; j < numberOfPrimes; j++) { | ||
for (int k = j; k < numberOfPrimes; k++) { | ||
int x = primes[i] + primes[j] + primes[k]; | ||
if (x > 100) { | ||
break; | ||
} | ||
a[x].a = primes[i]; | ||
a[x].b = primes[j]; | ||
a[x].c = primes[k]; | ||
} | ||
} | ||
} | ||
|
||
printf("不小于6的偶数都是两个素数之和:\n"); | ||
for (int i = 6; i <= 100; i+=2) { | ||
printf("%d = %d + %d\n",i,a[i].a,a[i].b); | ||
} | ||
printf("不小于9的偶数都是三个素数之和:\n"); | ||
for (int i = 9; i < 100; i+=2) { | ||
printf("%d = %d + %d + %d\n",i,a[i].a,a[i].b,a[i].c); | ||
} | ||
return 0; | ||
} | ||
|
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.
前面只写函数原型,函数的实现放到后面去