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

摸索着交个作业... #45

Open
wants to merge 54 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
8ae0892
Create C0
Flashkong Feb 23, 2017
0d37b80
Create C1
Flashkong Feb 23, 2017
459abc5
Create p01
Flashkong Feb 23, 2017
5e4c664
Create p02
Flashkong Feb 23, 2017
52e5fc5
Create p04
Flashkong Feb 23, 2017
68ca0ec
Create p05
Flashkong Feb 23, 2017
e09e1bf
Rename C0 to helloworld.c
Flashkong Mar 6, 2017
5c26851
Update and rename p02 to p02-isPrime.c
Flashkong Mar 6, 2017
07caa6d
Rename C1 to c1panduanshu.c
Flashkong Mar 6, 2017
e73f43b
Rename p04 to p04 shuixianshu.c
Flashkong Mar 6, 2017
3081dd5
Rename p05 to p05-allPrimes.c
Flashkong Mar 6, 2017
afdfd69
Create RunningLetter.c
Flashkong Mar 27, 2017
bd64562
Create isprime.c
Flashkong Mar 28, 2017
9736e55
Create Diophantus.c
Flashkong Apr 1, 2017
836bce3
Create narcissus.c
Flashkong Apr 1, 2017
b961323
Create allPrimers.c
Flashkong Apr 1, 2017
a05d35e
Create Goldbach.c
Flashkong Apr 1, 2017
413d81a
Create hanoi.c
Flashkong Apr 1, 2017
af0a055
Create maze.c
Flashkong Apr 7, 2017
090a297
Delete p01
Flashkong Apr 9, 2017
77b94ed
Delete p02-isPrime.c
Flashkong Apr 9, 2017
e7f3b34
Delete p04 shuixianshu.c
Flashkong Apr 9, 2017
6424039
Delete p05-allPrimes.c
Flashkong Apr 9, 2017
2c66d56
Create PushBoxs.c
Flashkong Apr 12, 2017
494b468
Create linklist.c
Flashkong Apr 13, 2017
d7d972a
Create encrypt_decrypt.c
Flashkong Apr 13, 2017
a6cdf75
Create Queue.cpp
Flashkong Apr 27, 2017
ba7b9ab
Create SafeArry.cpp
Flashkong Apr 27, 2017
6b5d5b1
Change Addback
Flashkong Apr 28, 2017
2fa1034
Updata procedure
Flashkong Apr 28, 2017
1e5c733
Submit Circle and Point
Flashkong May 3, 2017
4521c43
submit canvas
Flashkong May 3, 2017
de09a27
Update Canvas.cpp
Flashkong May 4, 2017
a2a2752
Update TodoList.md
Flashkong May 15, 2017
cb402e5
Update TodoList.md
Flashkong May 16, 2017
29a043e
Update TodoList.md
Flashkong May 16, 2017
ca447d6
Update TodoList.md
Flashkong May 17, 2017
3d551a1
Create flight.cpp
Flashkong May 18, 2017
b875fd9
Update flight.cpp
Flashkong May 18, 2017
a2de511
Update flight.cpp
Flashkong May 18, 2017
b7193bc
Update TodoList.md
Flashkong May 20, 2017
0662574
add one feature
Flashkong May 23, 2017
0d37747
achieve bullet and enemy_flight collide
Flashkong May 23, 2017
daee9de
Update TodoList.md
Flashkong May 23, 2017
c5d1987
add explotion animation and music
Flashkong May 23, 2017
90eb3ba
Update flight.cpp
Flashkong May 23, 2017
3e6d9bd
Update README.md
Flashkong Jun 5, 2017
587a0f5
Update README.md
Flashkong Jun 5, 2017
4baf6a0
Create ReadmeFirst
Flashkong Jun 12, 2017
be41a2e
Create ReadmeFirst.md
Flashkong Jun 12, 2017
b501c1b
Delete flight.cpp
Flashkong Jun 12, 2017
ceb67fc
Create TodoList.md
Flashkong Jun 12, 2017
79094cb
Create TodoList.md
Flashkong Jun 13, 2017
6f04154
Create READMEFIRST.md
Flashkong Jun 13, 2017
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
23 changes: 23 additions & 0 deletions practices/c/level0/c1panduanshu.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# include <stdio.h>

int main()
{
int input;
scanf("%d",&input);

if(input>0){
if(input%2==0){
printf("是正数而且是偶数\n");
}
else {
printf("是正数但不是偶数\n");
}
}
else if(input==0){
printf("既不是正数也不是负数\n");
}
else{
printf("是负数\n");
}
return 0;
}
8 changes: 8 additions & 0 deletions practices/c/level0/helloworld.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# include <stdio.h>

int main()
{
printf("Hello World! I'm 李帅锋!\n");

return 0;
}
26 changes: 26 additions & 0 deletions practices/c/level1/p01_runningLetter/RunningLetter.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# include<stdio.h>
# include<windows.h>

int main()
{
int i,j;
for(i=0;i<12;i++){
for(j=0;j<i;j++){
printf(" ");
}
Sleep(100);
printf("R");
system("cls");
}

for(i=12;i>0;i--){
for(j=0;j<i;j++){
printf(" ");
}
Sleep(100);
printf("R");
system("cls");
}

return 0;
}
23 changes: 23 additions & 0 deletions practices/c/level1/p02_isPrime/isprime.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# include<stdio.h>

int main()
{
int i,x = 0;
int infox=-1;
scanf("%d",&x);

for( i=2;i<x;i++){
if(x%i==0){
infox++;
}
}

if(infox==-1){
printf("是素数\n");
}
else {
printf("不是素数\n");
}

return 0;
}
13 changes: 13 additions & 0 deletions practices/c/level1/p03_Diophantus/Diophantus.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <stdio.h>

int main(void)
{
// age/6+age/12+age/7+5 = age-age/2-4
for(int i=10;i<=120;i++){
if(i%6 == 0 && i%12 == 0 && i%7 == 0){
printf("His age is %d",i);
}
}

return 0;
}
23 changes: 23 additions & 0 deletions practices/c/level1/p04_ narcissus/narcissus.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include <stdio.h>
# include<math.h>

int main(void)
{
int shuixianshu;
int baiwei,shiwei,gewei;

printf("三位水仙数如下:\n");

for(int i = 100;i<1000;i++){
baiwei = i/100;
shiwei = (i%100)/10;
gewei = i%10;

if(i==pow(baiwei,3)+pow(shiwei,3)+pow(gewei,3)){
shuixianshu = i;
printf("%d\t",shuixianshu);
}
}

return 0;
}
44 changes: 44 additions & 0 deletions practices/c/level1/p05_allPrimes/allPrimers.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#include <stdio.h>
#include<time.h>

int isPrimer(int num);

int main()
{
clock_t start,finish;
start = clock();
int primer;


for(int i = 2;i<=1000;i++){
primer = isPrimer(i);
if(primer){
printf("%d\n",i);
}
}

printf("the running time is:\t");
finish = clock();
double time = (double)(finish-start)*1000/CLOCKS_PER_SEC;
printf("%lf ms",time);

return 0;
}

int isPrimer(int num){
int result = 0;
int cnt = 0;

for(int i = 2;i<=sqrt(num);i++){
if(num%i==0) {
cnt++;
break;
}
}

if(cnt==0){
result = 1;
}

return result;
}
52 changes: 52 additions & 0 deletions practices/c/level1/p06_Goldbach/Goldbach.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#include <stdio.h>
#include<time.h>

int isPrimer(int num);

int main()
{
int primer[25];
int cnt = 0;
for(int i = 2;i<100;i++){
if(isPrimer(i)) {
primer[cnt] = i;
cnt++;
}
}

for(int i=3;i<=100;i++){
if(i%2==0){
for(int m = 0;m<=25;m++){
for(int n = 0;n<=25;n++){
if(primer[m]+primer[n]==i){
printf("%d=%d+%d\n",i,primer[m],primer[n]);
}
}
}
}
}

printf("So,we can learn that Goldbach's suspect is right in 0-100.\n");
return 0;
}

int isPrimer(int num){
int result = 0;
int cnt = 0;

for(int i = 2;i<=sqrt(num);i++){
if(num%i==0) {
cnt++;
break;
}
}

if(cnt==0){
result = 1;
}

return result;
}



26 changes: 26 additions & 0 deletions practices/c/level1/p07_encrypt_decrypt/encrypt_decrypt.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include <stdio.h>
#include <string.h>
char s[50000];
void encrypt();
void decrypt();
int main()
{
scanf("%s", s);
encrypt();
printf("%s\n", s);
decrypt();
printf("%s\n", s);
return 0;
}
void encrypt()
{
int i;
for (i = 0; i < strlen(s); i++)
s[i] += 5;
}
void decrypt()
{
int i;
for (i = 0; i < strlen(s); i++)
s[i] -= 5;
}
28 changes: 28 additions & 0 deletions practices/c/level1/p08_hanoi/hanoi.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# include<stdio.h>

int i= 0;

int main()
{
int N;
printf("input positive integer N: ");
scanf("%d",&N);

move('a','b','c',N);

printf("these are all steps!");
return 0;
}

void move(char str1,char str2,char str3,int n)
{
if(n==1){
printf("the %dst step:\t",++i);
printf("%c->%c\n",str1,str3);
}else{
move(str1,str3,str2,n-1);
printf("the %dst step:\t",++i);
printf("%c->%c\n",str1,str3);
move(str2,str1,str3,n-1);
}
}
110 changes: 110 additions & 0 deletions practices/c/level1/p09_maze/maze.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# include<stdio.h>
# include<stdlib.h>
#include <conio.h>
# define SIZE 10

int maze[SIZE][SIZE] = {
1,1,1,1,1,1,1,1,1,1,
1, 0, 0, 0, 1, 0, 1, 1, 0, 1,
1, 0, 1, 0, 0, 0, 1, 0, 0, 1,
1,0,0,1,0,1,1,1,0,1,
1,1,0,1,0,1,0,0,1,1,
1,0,0,1,0,0,0,1,0,1,
1,1,0,0,1,1,1,0,0,1,
1,1,1,0,0,0,1,1,0,1,
1,0,0,0,1,0,0,0,0,1,
1,1,1,1,1,1,1,1,1,1

};

void begin()
{
printf("this is a small maze game\n");
printf("please enter any key to continue...");
getchar();
system("cls");
for (int i = 0; i < 40; i++) {
printf("Maze generation...");
system("cls");
}
}

void show_maze(int prex,int prey,char c,int cnt)
{
system("cls");
int i, j;

for ( i = 0; i < SIZE; i++) {
for ( j = 0; j < SIZE; j++) {
if (maze[i][j]==1) printf("%c%c", 0xa8, 0x80);
else if (i == prey&&j == prex) printf("**");
else printf(" ");
if (j == SIZE - 1) printf("\n");
}
}
if (cnt) {
printf("You can't head to a wall!!\n");
}
}

int ifhead(int *nowx, int *nowy,char c)
{
if (maze[*nowy][*nowx] == 1) {

switch (c)
{
case 72:
*nowy += 1;
break;
case 75:
*nowx += 1;
break;
case 80:
*nowy -= 1;
break;
case 77:
*nowx -= 1;
break;
}
return 1;
}
return 0;
}

int main()
{
int k = 0, cnt = 0;
int nowx = 1, nowy = 1;
begin();
show_maze(1,1,0,cnt);

while (1) {
char c = _getch();

switch (c)
{
case 72:
nowy -= 1;
break;
case 75:
nowx -= 1;
break;
case 80:
nowy += 1;
break;
case 77:
nowx += 1;
break;
}
cnt = ifhead(&nowx, &nowy, c);
show_maze(nowx, nowy, c,cnt);

if (nowx == SIZE - 2 && nowy == SIZE - 2) {
printf("Congratulations,You have passed this game!\n");
break;
}
}

system("pause");
return 0;
}
Loading