-
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
交作业 #57
Open
winterYANGWT
wants to merge
20
commits into
luckymark:master
Choose a base branch
from
winterYANGWT: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
交作业 #57
Changes from 4 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
e49c98e
交作业
winterYANGWT 300a141
finished safearray
winterYANGWT 367860a
1:changed safearray
winterYANGWT 52f4026
2:changed safearray
winterYANGWT eee45c5
finished scoremanagement
winterYANGWT 781726c
Update running letter.c
winterYANGWT 7dae185
Update IsPrime.c
winterYANGWT a3d2e89
finished Circuit(naive version)
winterYANGWT 9c8d348
finished EmployeeAndSales(naive version)
winterYANGWT f629869
finished Canvas(naive version)
winterYANGWT cfe45e0
finished CircleandPoint(naive Version)
winterYANGWT d0289c9
SFML learn
winterYANGWT b847e45
finished 1 2 3 4
winterYANGWT 6afb380
change some file,add Resource management
winterYANGWT 43f2501
error code c2280
winterYANGWT 25defc3
update?
winterYANGWT 5b5cf86
new file
winterYANGWT c7d69d7
clear
winterYANGWT d020418
finished
winterYANGWT 8198b6a
hello world
winterYANGWT 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,31 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include<windows.h> | ||
int main(void) | ||
{ | ||
printf("please input a character:"); | ||
char ch; | ||
scanf_s("%c",&ch); | ||
int a=0; | ||
for(;a<100;++a) | ||
{ | ||
system("cls"); | ||
Sleep(100); | ||
int i=0; | ||
for(;i<a;++i) | ||
printf(" "); | ||
printf("%c",ch); | ||
} | ||
for(;!(a<0);a--) | ||
{ | ||
system("cls"); | ||
Sleep(100); | ||
int i=0; | ||
for(;i<a;++i) | ||
printf(" "); | ||
printf("%c",ch); | ||
} | ||
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,31 @@ | ||
#include<stdio.h> | ||
#include<stdlib.h> | ||
#include<stdbool.h> | ||
bool check(int n); | ||
int main(void) | ||
{ | ||
int num; | ||
printf("please input a number : "); | ||
scanf_s("%d", &num); | ||
getchar(); | ||
while (num <= 1) | ||
{ | ||
printf("error, please input a number is above 1 :"); | ||
scanf_s("%d", &num); | ||
getchar(); | ||
} | ||
if (check(num)) | ||
printf("\n%d is a prime", num); | ||
else | ||
printf("\n%d is not a prime", num); | ||
getchar(); | ||
return 0; | ||
} | ||
|
||
bool check(int n) | ||
{ | ||
for (int i = 2; i < n; ++i) | ||
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. 循环体和if语句都要用大括号包起来 |
||
if (!(n%i)) | ||
return false; | ||
return true; | ||
} |
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,14 @@ | ||
#include<stdio.h> | ||
int main(void) | ||
{ | ||
for (int i = 10; i <= 100; ++i) | ||
{ | ||
if (84 * i == 84 * 9 + 75 * i) { | ||
printf("when his son died his age is %d", i - 4); | ||
getchar(); | ||
return 0; | ||
} | ||
|
||
} | ||
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,16 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include<math.h> | ||
int main(void) | ||
{ | ||
for(int i=100;i<1000;++i) | ||
{ | ||
int a=i/100; | ||
int b=i%100/10; | ||
int c=i%100%10; | ||
if(i==pow(a,3)+pow(b,3)+pow(c,3)) | ||
printf("%d ",i); | ||
} | ||
getchar(); | ||
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,34 @@ | ||
#include<stdio.h> | ||
#include<time.h> | ||
#include<stdbool.h> | ||
bool check(int n, int array[]); | ||
int main(void) | ||
{ | ||
double op = clock(); | ||
int array[10000]; | ||
array[0] = 2; | ||
array[1] = 0; | ||
int num = 1; | ||
for(int i=3;i<=10000;++i) | ||
if (check(i, array)) | ||
{ | ||
array[num] = i; | ||
++num; | ||
array[num] = 0; | ||
} | ||
for (int a = 0; a < num; ++a) | ||
printf("%d\n", array[a]); | ||
double ed = clock(); | ||
printf("%lf",(ed - op)/1000); | ||
getchar(); | ||
return 0; | ||
} | ||
|
||
bool check(int n, int array[]) | ||
{ | ||
|
||
for (int i = 0; array[i] != 0; ++i) | ||
if (!(n%array[i])) | ||
return false; | ||
return true; | ||
} |
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,42 @@ | ||
#include<stdio.h> | ||
#include<stdbool.h> | ||
#include<time.h> | ||
bool check(int n, int array[]); | ||
int main(void) | ||
{ | ||
double op, ed; | ||
op = clock(); | ||
int array[10000]; | ||
array[0] = 2; | ||
array[1] = 0; | ||
int num = 1; | ||
for (int i = 3; i <= 1000; ++i) | ||
if (check(i, array)) | ||
{ | ||
array[num] = i; | ||
++num; | ||
array[num] = 0; | ||
} | ||
for (int a = 4; a <= 1000; a += 2) | ||
for (int d = 0; array[d] != 0&&array[d]<=a/2+1; ++d) | ||
{ | ||
for (int e = 0; array[e] != 0; ++e) | ||
{ | ||
if (array[e] == a - array[d]) | ||
printf("%d=%d+%d\n", a, array[d], array[e]); | ||
} | ||
} | ||
ed = clock(); | ||
printf("%f", (ed - op) / 1000); | ||
getchar(); | ||
return 0; | ||
} | ||
|
||
bool check(int n, int array[]) | ||
{ | ||
|
||
for (int i = 0; array[i] != 0; ++i) | ||
if (!(n%array[i])) | ||
return false; | ||
return true; | ||
} |
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,23 @@ | ||
#include<stdio.h> | ||
void hanoi(int n, char a, char b, char c); | ||
int main(void) | ||
{ | ||
printf("please input the number you want: "); | ||
int num; | ||
scanf_s("%d", &num); | ||
getchar(); | ||
hanoi(num, 'a', 'b', 'c'); | ||
getchar(); | ||
return 0; | ||
} | ||
|
||
void hanoi(int n, char a, char b, char c) | ||
{ | ||
if (n == 1) | ||
printf("%d: %c>>%c\n", n, a, c); | ||
else { | ||
hanoi(n - 1, a, c, b); | ||
printf("%d :%c>>%c\n", n, a, c); | ||
hanoi(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,119 @@ | ||
#include<stdio.h> | ||
#include <windows.h> | ||
#include <stdlib.h> | ||
#include <conio.h> | ||
#include<stdbool.h> | ||
struct maze | ||
{ | ||
int x; | ||
int y; | ||
int dir; | ||
}; | ||
char m[30][30]; | ||
struct maze man; | ||
const int xdir[5] = { 0, 1, 0, -1 ,0};//w a s d | ||
const int ydir[5] = { -1,0,1,0 ,0};//w a s d | ||
void map(void); | ||
void show(void); | ||
void ini(void); | ||
void turn(void); | ||
bool check(void); | ||
void move(void); | ||
void show0(void); | ||
int main(void) | ||
{ | ||
ini(); | ||
show(); | ||
while (true) | ||
{ | ||
Sleep(60); | ||
system("cls"); | ||
turn(); | ||
if (check()) | ||
move(); | ||
man.dir = 4; | ||
show(); | ||
} | ||
getchar(); | ||
return 0; | ||
} | ||
|
||
void map(void) | ||
{ | ||
for (int i = 0; i < 30; ++i) | ||
m[0][i] = '*'; | ||
for (int a = 4; a < 30; ++a) | ||
m[a][0] = '*'; | ||
for (int b = 1; b < 25; ++b) | ||
m[29][b] = '*'; | ||
for (int c = 1; c < 30; ++c) | ||
m[c][29] = '*'; | ||
for (int a = 5; a < 10; ++a) | ||
m[a][4] = '*'; | ||
for (int b = 1; b < 5; ++b) | ||
m[4][b] = '*'; | ||
for (int i = 1; i < 20; ++i) | ||
m[i][14] = '*'; | ||
for (int i = 9; i < 20; ++i) | ||
m[19][i] = '*'; | ||
for (int i = 24; i < 30; ++i) | ||
m[4][i] = '*'; | ||
for (int i = 14; i < 29; ++i) | ||
m[i][24] = '*'; | ||
} | ||
|
||
void show(void) | ||
{ | ||
for (int a = 0; a < 30; ++a) | ||
{ | ||
for (int b = 0; b < 30; ++b) | ||
printf("%c", m[a][b]); | ||
printf("\n"); | ||
} | ||
} | ||
|
||
void ini(void) | ||
{ | ||
map(); | ||
man.x = 0; | ||
man.y = 1; | ||
m[man.y][man.x] = 'H'; | ||
} | ||
|
||
void turn(void) { | ||
if (_kbhit()) { | ||
char dir = _getch(); //读取输入的键 | ||
switch (dir) { //改变方向 | ||
case 119: man.dir = 0; break; | ||
case 100: man.dir =1; break; | ||
case 115: man.dir = 2; break; | ||
case 97: man.dir =3; break; | ||
} | ||
} | ||
} | ||
|
||
bool check(void) | ||
{ | ||
if (m[man.y + ydir[man.dir]][man.x + xdir[man.dir]] == '*') | ||
return false; | ||
else | ||
return true; | ||
|
||
} | ||
|
||
void move(void) | ||
{ | ||
m[man.y][man.x] = ' '; | ||
man.x = man.x + xdir[man.dir]; | ||
man.y = man.y + ydir[man.dir]; | ||
m[man.y][man.x] = 'H'; | ||
} | ||
|
||
void show0(void) | ||
{ | ||
for (int a = 0; a < man.y; ++a) | ||
for (int b = 0; b < man.x; ++b) | ||
if (m[man.y][man.x] == 'H') | ||
printf("%c", m[man.y][man.x]); | ||
|
||
} |
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.
缩进!