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

陈小羽 homework #47

Open
wants to merge 71 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
9bd1315
v1
jianx312035 Feb 22, 2017
bbc8b00
c/C1/1
jianx312035 Feb 22, 2017
996decf
c/c0/2
jianx312035 Feb 22, 2017
d41f6f7
c/level0/c1/3
jianx312035 Feb 22, 2017
decfc01
running letter
jianx312035 Feb 22, 2017
83529ff
running letter -- written on Unix
jianx312035 Feb 22, 2017
1276962
p02_isPrime --written on Unix
jianx312035 Feb 23, 2017
1645250
p03_Diophantus --written on Unix
jianx312035 Feb 23, 2017
2dc692e
p04_ narcissus --written on Unix
jianx312035 Feb 23, 2017
cab536b
p05_allPrimes --written on Unix
jianx312035 Feb 23, 2017
4fd5790
p05_allPrimes --written on Unix
jianx312035 Feb 23, 2017
8acfefa
p06_Goldbach --written on Unix
jianx312035 Feb 23, 2017
d248dad
p07_encrypt_decrypt --written on Unix
jianx312035 Feb 23, 2017
2fa8677
p08_hanoi --written on Unix
jianx312035 Feb 23, 2017
552eebc
p01_Queue --written on Unix
jianx312035 Feb 23, 2017
79cde06
p09_maze --written on Unix
chenxiaoyu233 Feb 23, 2017
d6bab51
p09_maze --alpha --witten on Unix
jianx312035 Feb 25, 2017
2da4d83
p10_pushBoxes --written on Unix
jianx312035 Feb 25, 2017
286b3ae
p11_linkedList --written on Unix
jianx312035 Feb 28, 2017
28becc8
p12_warehouse --written on Unix
jianx312035 Feb 28, 2017
6b1bd16
change p01->p08 with c language --written on Unix
jianx312035 Mar 1, 2017
3999787
p11_warehouse --v1.1 --written on Unix
jianx312035 Mar 2, 2017
ac06a56
remove trash
jianx312035 Mar 2, 2017
2946e7c
level02-GA algorithm -- written on Unix
jianx312035 Mar 9, 2017
2bc4abd
move trash
jianx312035 Mar 9, 2017
863d416
c++ p01_Queue --written on Unix
jianx312035 Mar 28, 2017
c03b1b5
c++ p02_Stack -changeable length --written on Unix
jianx312035 Mar 30, 2017
5d3e9eb
c++ p03_SafeArray --written on Unix
jianx312035 Apr 11, 2017
af601e3
c++/p04 --written on unix
jianx312035 Apr 18, 2017
69377b0
c++/p06 --written on unix
jianx312035 Apr 18, 2017
fac8ff3
adjust of tabstop
jianx312035 Apr 19, 2017
97c31de
adjust according to suggestions
jianx312035 Apr 19, 2017
3f046be
p04 --Update Todolist
jianx312035 Apr 19, 2017
f3451e9
c++/p05-canvas --written on unix
jianx312035 Apr 27, 2017
c1622d6
c++/p07_circuit --written on Unix
jianx312035 Apr 28, 2017
2709016
c++/p02_stack --add template
jianx312035 May 4, 2017
a3f0f90
c++/p03-SafeArray --add template
jianx312035 May 4, 2017
82993b7
c++/p11_fighter --environment
jianx312035 May 10, 2017
0d43ef0
c++/p11_Fighter Basic_classes
jianx312035 May 14, 2017
7d87e62
c++/Fighter shot
jianx312035 May 14, 2017
b26e67e
c++/Fighter sf::Sound 全局bug修复
jianx312035 May 14, 2017
31cdd12
c++/p11_Fighter 添加背景和边界检测和子弹消亡动画
jianx312035 May 16, 2017
7434de9
c++/p11_Fighter 子弹声音bug修复
jianx312035 May 16, 2017
6da6cbf
c++/p11_fighter 代码整理
jianx312035 May 18, 2017
a910d10
c++/p11_fighter Enemy added
jianx312035 May 19, 2017
58cf0d9
c++/fighter 素材
jianx312035 May 20, 2017
4137b19
c++/fighter 物理引擎添加
jianx312035 May 20, 2017
c45a78c
c++/fighter 导演类翻新+代码整理
jianx312035 May 21, 2017
448a39c
c++/fighter 枚举代替数字
jianx312035 May 21, 2017
25565ac
c++/fighter 子弹物理效果
jianx312035 May 21, 2017
17694ab
c++/fighter Q技能添加+碰撞系统完善+主边界线+物件之间关系
jianx312035 May 21, 2017
3c8c36a
c++/fighter 清理sfml库文件安装包
jianx312035 May 21, 2017
955f1af
c++/fighter 清理sfml库文件
jianx312035 May 21, 2017
40e0abf
c++/p11_fighter 添加背景图片,修正技能释放效果
jianx312035 Jun 5, 2017
e0e6ad1
c++/p11_fighter 添加敌机子弹,影响
jianx312035 Jun 6, 2017
966c21c
c++/p11_figther 添加完全弹性碰撞效果
jianx312035 Jun 6, 2017
616df11
c++/p11_fighter 添加gal元素,修正物理类bug
jianx312035 Jun 9, 2017
9fc8716
c++/p11_fighter 添加CG类,炫酷,使用新方法对齐动画时间
jianx312035 Jun 9, 2017
4377690
c++/p11_fighter 添加作者名,添加了一些素材,修正了动画更新
jianx312035 Jun 10, 2017
f0f4993
c++/p11_fighter 添加新技能
jianx312035 Jun 10, 2017
ca22250
c++/p11_fighter 添加背景音乐
jianx312035 Jun 10, 2017
0187b0e
c++/p11_fighter 添加地图切换,过关控制
jianx312035 Jun 11, 2017
bc21172
c++/p11_fighter 添加敌机死亡动画,门的通过控制
jianx312035 Jun 11, 2017
461dca2
c++/p11_fighter 添加地图,胜利判断
jianx312035 Jun 11, 2017
488e21e
c++/p11_fighter 收尾工作
jianx312035 Jun 11, 2017
9d422a6
c++/p11_fighter 基本收工
jianx312035 Jun 11, 2017
c19d775
c++/p11_fighter 重大bug修复
jianx312035 Jun 12, 2017
029108e
c++/p11_fighter 添加帧率检测
jianx312035 Jun 19, 2017
b361c5a
c++/p08_EmployeeAndSales finish
jianx312035 Jun 23, 2017
766a455
c++/p09_Tree finish
jianx312035 Jun 23, 2017
88c07c0
c++/p10_Iterator finish
jianx312035 Jun 23, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Binary file added .DS_Store
Binary file not shown.
Binary file added practices/.DS_Store
Binary file not shown.
Binary file added practices/c/.DS_Store
Binary file not shown.
6 changes: 6 additions & 0 deletions practices/c/level0/C0/1.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//测试一下git
#include <stdio.h>
int main(){
printf("Hello World I'm Chenxiaoyu\n");
return 0;
}
2 changes: 2 additions & 0 deletions practices/c/level0/C0/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
main: 1.c
cc 1.c
17 changes: 17 additions & 0 deletions practices/c/level0/C1/1.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <stdio.h>
#include <string.h>
char ans1[3][10] = {"正数","负数","0"};
char ans2[2][10] = {"奇数","偶数"};
char *ans[2];
int sgn(int n){
if(n == 0) return 2;
return n > 0 ? 0 : 1;
}
int main(){
int n;
scanf(" %d",&n);
ans[0] = ans1[sgn(n)];
ans[1] = n % 2 ? ans2[0] : ans2[1];
printf("%s %s", ans[0], ans[1]);
return 0;
}
7 changes: 7 additions & 0 deletions practices/c/level0/C1/2.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include <stdio.h>
int main(){
int n;
scanf(" %d", &n);
printf("%s\n",(n % 13 == 0 ? "YES" : "NO"));
return 0;
}
8 changes: 8 additions & 0 deletions practices/c/level0/C1/3.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <stdio.h>
int main(){
int n;
scanf(" %d",&n);
printf("%s\n",( n % 4 == 0 && n % 100 != 0) || (n % 400 == 0) ? "YES" : "NO");
return 0;
}
///算法来自百度
6 changes: 6 additions & 0 deletions practices/c/level0/C1/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
my1: 1.c
cc 1.c
my2: 2.c
cc 2.c
my3: 3.c
cc 3.c
2 changes: 2 additions & 0 deletions practices/c/level1/p01_runningLetter/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
main: my.c
cc -lcurses my.c -g -o my.c.out
24 changes: 24 additions & 0 deletions practices/c/level1/p01_runningLetter/my.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//written on unix
#include <stdio.h>
#include <curses.h>
void delay(){
for(int i = 1; i <= 50000000; i++);
}
int main(){
initscr();
int pos = 0,dir = 1;
while(1){
int col = COLS - 1;
mvaddch(0,pos,'R');
refresh();
delay();
if(pos == 0)
dir = 1;
if(pos == col)
dir = -1;
mvaddch(0,pos,' ');
pos += dir;
}
endwin();
return 0;
}
2 changes: 2 additions & 0 deletions practices/c/level1/p02_isPrime/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
main: my.c
cc my.c -o my.c.out -g
14 changes: 14 additions & 0 deletions practices/c/level1/p02_isPrime/my.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include <string.h>
#include <stdio.h>
int main(){
int n;
scanf("%d",&n);
int flag = 1;
for(int i = 2; i*i <= n; i++)
if(n % i == 0){
flag = 0;
break;
}
printf("%s\n",(flag == 1 ? "YES" : "NO"));
return 0;
}
9 changes: 9 additions & 0 deletions practices/c/level1/p03_Diophantus/my.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include <stdio.h>
int main(){
for(int i = 0; i <= 200; i+=7*12){
if(2 * ( (i - 4) - (i / 7 + i / 6 + i / 12 + 5)) == i){
printf("%d\n", i - 4);
}
}
return 0;
}
12 changes: 12 additions & 0 deletions practices/c/level1/p04_ narcissus/my.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <stdio.h>
int pow_3(int x){
return x * x * x;
}
int main(){
for(int i = 100; i <= 999; i++){
int cur = pow_3( i % 10 ) + pow_3( (i/10) % 10 ) + pow_3( i / 100 );
if(cur == i)
printf("%d\n", i);
}
return 0;
}
40 changes: 40 additions & 0 deletions practices/c/level1/p05_allPrimes/my.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//#include <cstring>
#include <cstdio>
#include <sys/time.h>
//#include <numeric>
//#include <chrono>
#define maxn 2005
//using namespace std;
int prime[maxn];
int not_prime[maxn];
int cnt_prime;
void get_prime(){
for(int i = 2; i <= 2000; i++){
if(!not_prime[i]) prime[++cnt_prime] = i;
for(int j = 1; j <= cnt_prime; j++){
if(i * prime[j] > 2000) break;
not_prime[i * prime[j]] = 1;
if(i % prime[j] == 0) break;
}
}
}
void work(){
get_prime();
for(int i = 1; i <= cnt_prime; i++){
printf("%d ",prime[i]);
}
printf("\n");
}
int main(){
struct timeval start, end;
gettimeofday( &start, NULL );

work();

gettimeofday( &end, NULL );
float timeuse = 1e6 * (end.tv_sec - start.tv_sec) + end.tv_usec - start.tv_usec;
timeuse *= 1e-6;
printf("Total time: %f\n", timeuse);
return 0;

}
33 changes: 33 additions & 0 deletions practices/c/level1/p06_Goldbach/my.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include <string.h>
#include <stdio.h>
#define maxn 105
int prime[maxn];
int not_prime[maxn];
int cnt_prime;
void get_prime(){
for(int i = 2; i <= 100; i++){
if(!not_prime[i]) prime[++cnt_prime] = i;
for(int j = 1; j <= cnt_prime; j++){
if(i * prime[j] > 100) break;
not_prime[i * prime[j]] = 1;
if(i % prime[j] == 0) break;
}
}
}
int main(){
get_prime();
int flag = 1;
for(int i = 4; i <= 100; i += 2){
int cur = 0;
for(int j = 2; j <= i-2; j++){
if(!not_prime[j] && !not_prime[i-j]){
cur = 1; break;
}
}
if(cur == 0){
flag = 0; break;
}
}
printf("%s\n", (flag == 1 ? "right" : "wrong") );
return 0;
}
36 changes: 36 additions & 0 deletions practices/c/level1/p07_encrypt_decrypt/my.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/* useage */
/* whe you use encrypt, the program will return you a seed, and you should use the seed to decrypt the code */
/* example:
$./my.cpp.out encrypt abcde
WXYZ[ 10
$./my.cpp.out decrypt WXYZ[ 10
abcde
*/
#include <string.h>
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
void en(char s[]){
int len = strlen(s);
int now = rand() % 30;
for(int i = 0; i < len; i++){
printf("%c", (char) (s[i] - now));
}
printf(" %d%d\n", now/10,now%10);
}
void de(char s[],char ti[]){
int len = strlen(s);
int now = 10 * (ti[0] - '0') + ti[1] - '0';
for(int i = 0; i < len; i++){
printf("%c", (char) (s[i] + now) );
}
printf("\n");
}
int main(int argc,char *argv[]){
srand(time(NULL));
if(argv[1][0] == 'e')
en(argv[2]);
else
de(argv[2],argv[3]);
return 0;
}
18 changes: 18 additions & 0 deletions practices/c/level1/p08_hanoi/my.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//this program will print the solution of hanoi of n discs
#include <stdio.h>
#include <string.h>
void dfs(int num,int a,int b,int c){
if(num == 1){
printf("%d -> %d\n", a,c);
return;
}
dfs(num-1,a,c,b);
dfs(1,a,b,c);
dfs(num-1,b,a,c);
}
int main(){
int n;
scanf("%d",&n);
dfs(n,1,2,3);
return 0;
}
2 changes: 2 additions & 0 deletions practices/c/level1/p09_maze/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
main: my.c
cc -lcurses -g -o my.c.out my.c
18 changes: 18 additions & 0 deletions practices/c/level1/p09_maze/map1
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
17 47
###############################################
###############################################
#### $############################
#### ######## ############## ########
#### ######## #### ######### ########
#### ####### ############## # # ########
#### #### ############### # ##### # ########
####### #### ### # @# # ########
####### #### ######## ###### ####### # ########
####### ####### ###### # ########
############# ####### ################ ########
##################### ########
##################### #########################
############# #########################
###############################################
###############################################
###############################################
19 changes: 19 additions & 0 deletions practices/c/level1/p09_maze/map2
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
18 45
#############################################
############ ##### ##################
############ ############# ##################
############ ## # ##################
############ ## ########## # #########
############ ## #* ##### ######## #########
############ ## #### ##### #% # #########
############ ## #### ##### ### #### #########
############ ## # ##### ### #### #########
############ ## #### ##### ### #### #########
############### #### ##### ### #### #########
#################### ##### ### #### #########
###### *# ##### # @# #########
###### ############# ##### ######## #########
###### #############%##### #########
###### ######################################
######^######################################
# #
Loading