From 1461d81332d6980632495d1f30285802607a0b41 Mon Sep 17 00:00:00 2001 From: jinshayumi <791682161@QQ.COM> Date: Mon, 27 Feb 2017 23:46:04 +0800 Subject: [PATCH 01/39] Add files via upload --- .../1\344\270\207\344\275\240\345\245\275.c" | 7 ++++ ...\345\210\260100\345\201\266\346\225\260.c" | 7 ++++ .../c/level0/3\344\270\252\346\225\260.c" | 21 +++++++++++ ...445\344\270\215\346\225\264\351\231\244.c" | 10 ++++++ .../c/level0/5\344\270\252\346\225\260.c" | 16 +++++++++ ...252\346\257\224\345\244\247\345\260\217.c" | 23 ++++++++++++ practices/c/level0/99.c | 22 ++++++++++++ practices/c/level0/JCC.c | 17 +++++++++ practices/c/level0/hello.c | 5 +++ .../n\344\270\252\345\244\247\345\260\217.c" | 25 +++++++++++++ .../c/level0/n\344\270\252\346\225\260.c" | 22 ++++++++++++ practices/c/level0/zj.c | 36 +++++++++++++++++++ .../c/level0/\345\245\207\345\201\266 13.c" | 26 ++++++++++++++ .../\350\267\2377\346\234\211\345\205\263.c" | 8 +++++ .../c/level0/\351\227\260\345\271\264.c" | 11 ++++++ 15 files changed, 256 insertions(+) create mode 100644 "practices/c/level0/1\344\270\207\344\275\240\345\245\275.c" create mode 100644 "practices/c/level0/2\345\210\260100\345\201\266\346\225\260.c" create mode 100644 "practices/c/level0/3\344\270\252\346\225\260.c" create mode 100644 "practices/c/level0/3\346\225\264\351\231\2445\344\270\215\346\225\264\351\231\244.c" create mode 100644 "practices/c/level0/5\344\270\252\346\225\260.c" create mode 100644 "practices/c/level0/5\344\270\252\346\257\224\345\244\247\345\260\217.c" create mode 100644 practices/c/level0/99.c create mode 100644 practices/c/level0/JCC.c create mode 100644 practices/c/level0/hello.c create mode 100644 "practices/c/level0/n\344\270\252\345\244\247\345\260\217.c" create mode 100644 "practices/c/level0/n\344\270\252\346\225\260.c" create mode 100644 practices/c/level0/zj.c create mode 100644 "practices/c/level0/\345\245\207\345\201\266 13.c" create mode 100644 "practices/c/level0/\350\267\2377\346\234\211\345\205\263.c" create mode 100644 "practices/c/level0/\351\227\260\345\271\264.c" diff --git "a/practices/c/level0/1\344\270\207\344\275\240\345\245\275.c" "b/practices/c/level0/1\344\270\207\344\275\240\345\245\275.c" new file mode 100644 index 00000000..a1baf142 --- /dev/null +++ "b/practices/c/level0/1\344\270\207\344\275\240\345\245\275.c" @@ -0,0 +1,7 @@ +#include +main() +{ + int i; + for(i=1;i<=10000;i++) + printf("hello "); + } diff --git "a/practices/c/level0/2\345\210\260100\345\201\266\346\225\260.c" "b/practices/c/level0/2\345\210\260100\345\201\266\346\225\260.c" new file mode 100644 index 00000000..42c9e635 --- /dev/null +++ "b/practices/c/level0/2\345\210\260100\345\201\266\346\225\260.c" @@ -0,0 +1,7 @@ +#include +main() +{ + int a; + for(a=2;a<=100;a=a+2) + printf("%d ",a); + } diff --git "a/practices/c/level0/3\344\270\252\346\225\260.c" "b/practices/c/level0/3\344\270\252\346\225\260.c" new file mode 100644 index 00000000..688723f4 --- /dev/null +++ "b/practices/c/level0/3\344\270\252\346\225\260.c" @@ -0,0 +1,21 @@ +#include +void main() +{ + int a,b,c; + printf("输入三个数:"); + scanf("%d %d %d",&a,&b,&c); + if(a>b) + { + if(a>c) + printf("最大的为%d",a); + else + printf("最大的为%d",c); + } + else + { + if(b +main() +{ + int a; + for(a=1;a<=100;a++) + { + if(a%3==0&&a%5!=0) + printf("%d\n",a); + } +} diff --git "a/practices/c/level0/5\344\270\252\346\225\260.c" "b/practices/c/level0/5\344\270\252\346\225\260.c" new file mode 100644 index 00000000..5e155522 --- /dev/null +++ "b/practices/c/level0/5\344\270\252\346\225\260.c" @@ -0,0 +1,16 @@ +#include +main() +{ + int a[5]; + printf("输入5个数"); + int i,b; + for(i=1;i<=5;i++) + { + scanf("%d",&a[i]); + } + printf("没有出现的数为"); + for(b=0;b<=9;b++) + if(b!=a[1]&&b!=a[2]&&b!=a[3]&&b!=a[4]&&b!=a[5]) + printf("%d",a[i]); + +} diff --git "a/practices/c/level0/5\344\270\252\346\257\224\345\244\247\345\260\217.c" "b/practices/c/level0/5\344\270\252\346\257\224\345\244\247\345\260\217.c" new file mode 100644 index 00000000..4febba14 --- /dev/null +++ "b/practices/c/level0/5\344\270\252\346\257\224\345\244\247\345\260\217.c" @@ -0,0 +1,23 @@ +#include +void main() +{ + int a,b,k; + const n=5; + int i[n]; + printf("请输入5个0-9的数:\n"); + for(a=1;a<=n;a++) + { + printf("i[%d]=",a); + scanf("%d",&i[a]); + } + for(a=1;ai[b+1]) + { + k=i[b]; + i[b]=i[b+1]; + i[b+1]=k; + } + for(a=1;a<=n;a++) + printf("%d\n",i[a]); + } diff --git a/practices/c/level0/99.c b/practices/c/level0/99.c new file mode 100644 index 00000000..3380b86c --- /dev/null +++ b/practices/c/level0/99.c @@ -0,0 +1,22 @@ +#include +int main() +{ + int a,b,c; + printf(" *"); + for(a=1;a<=9;a++) + { + printf("%4d",a); + } + printf("\n"); + for(a=1;a<=9;a++) + { + printf("%4d",a); + for(b=1;b<=a;b++) + { + c=a*b; + printf("%4d",c); + } + printf("\n"); + } + +} diff --git a/practices/c/level0/JCC.c b/practices/c/level0/JCC.c new file mode 100644 index 00000000..ae23b655 --- /dev/null +++ b/practices/c/level0/JCC.c @@ -0,0 +1,17 @@ +#include +int jc(int a) +{ + int b=1,i; + for(i=1;i<=a;i++) + b*=i; + return b; + } + void main() + { + int x,y; + printf("输入整数:"); + scanf("%d",&x); + y=jc(x); + printf("jc=%d",y); + } + diff --git a/practices/c/level0/hello.c b/practices/c/level0/hello.c new file mode 100644 index 00000000..41e35e31 --- /dev/null +++ b/practices/c/level0/hello.c @@ -0,0 +1,5 @@ +#include +main() +{ +printf("hello world,I am Guohu!"); +} diff --git "a/practices/c/level0/n\344\270\252\345\244\247\345\260\217.c" "b/practices/c/level0/n\344\270\252\345\244\247\345\260\217.c" new file mode 100644 index 00000000..81b3e8e6 --- /dev/null +++ "b/practices/c/level0/n\344\270\252\345\244\247\345\260\217.c" @@ -0,0 +1,25 @@ +#include +main() +{ + int n; + printf("n的值为:"); + scanf("%d",&n); + int i,j,k; + int a[n]={0}; + for(i=1;i<=n;i++) + { + printf("a[%d]:",i); + scanf("%d",&a[i]); + } + for(i=1;i<=n-1;i++) + for(j=1;j +int main() +{ + int m,n,a,i; + m=1; + + printf("n的值为:"); + scanf("%d",&n); + printf("输入n个数"); + + for(i=1;i<=n;i++) + { + scanf("%d",&a); + printf("\n"); + if(a>m) + { + m=a; + + } + } + printf("最大的数为%d",m); + } diff --git a/practices/c/level0/zj.c b/practices/c/level0/zj.c new file mode 100644 index 00000000..0c118512 --- /dev/null +++ b/practices/c/level0/zj.c @@ -0,0 +1,36 @@ +#include +double zj(float a,float b,float c) +{ + float d; + if(a +main() +{ + int a; + printf("输入a的值:"); + scanf("%d",&a); + + if(a>0) + printf("a为正数"); + else if(a==0) + printf("a为0"); + else + printf("a为负数"); + printf("\n"); + + if(a%2==0) + printf("a为偶数"); + else + printf("a为奇数"); + printf("\n"); + + if(a%13==0) + printf("a为13倍数"); + else + printf("a不为13倍数"); +} diff --git "a/practices/c/level0/\350\267\2377\346\234\211\345\205\263.c" "b/practices/c/level0/\350\267\2377\346\234\211\345\205\263.c" new file mode 100644 index 00000000..d2c57b11 --- /dev/null +++ "b/practices/c/level0/\350\267\2377\346\234\211\345\205\263.c" @@ -0,0 +1,8 @@ +#include +main() +{ + int a; + for(a=1;a<+100;a++) + if(a%7==0||a%10==7) + printf("%d\n",a); + } diff --git "a/practices/c/level0/\351\227\260\345\271\264.c" "b/practices/c/level0/\351\227\260\345\271\264.c" new file mode 100644 index 00000000..cfeff527 --- /dev/null +++ "b/practices/c/level0/\351\227\260\345\271\264.c" @@ -0,0 +1,11 @@ +#include +int main() +{ + int a; + printf("输入年份:"); + scanf("%d",&a); + if(a%400==0||a%100!=0&&a%4==0) + printf("a为闰年"); + else + printf("a不为闰年"); +} From 6e01ae9719a65c2ee280f90a7ada4bf3e0de3109 Mon Sep 17 00:00:00 2001 From: jinshayumi <791682161@QQ.COM> Date: Wed, 1 Mar 2017 22:48:13 +0800 Subject: [PATCH 02/39] =?UTF-8?q?Create=20L0=EF=BC=8CL1PART?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "practices/c/level0/L0\357\274\214L1PART" | 204 ++++++++++++++++++++++ 1 file changed, 204 insertions(+) create mode 100644 "practices/c/level0/L0\357\274\214L1PART" diff --git "a/practices/c/level0/L0\357\274\214L1PART" "b/practices/c/level0/L0\357\274\214L1PART" new file mode 100644 index 00000000..3dadbfa1 --- /dev/null +++ "b/practices/c/level0/L0\357\274\214L1PART" @@ -0,0 +1,204 @@ +#include +main() +{ + int i; + for(i=1;i<=10000;i++) + printf("hello "); + } + + + +#include +main() +{ + int a; + for(a=2;a<=100;a=a+2) + printf("%d ",a); + } + + + + #include +void main() +{ + int a,b,c; + printf("杈撳叆涓変釜鏁帮細"); + scanf("%d %d %d",&a,&b,&c); + if(a>b) + { + if(a>c) + printf("鏈澶х殑涓%d",a); + else + printf("鏈澶х殑涓%d",c); + } + else + { + if(b +main() +{ + int a; + for(a=1;a<=100;a++) + { + if(a%3==0&&a%5!=0) + printf("%d\n",a); + } +} + + +#include +void main() +{ + int a,b,k; + const n=5; + int i[n]; + printf("璇疯緭鍏5涓0-9鐨勬暟锛歕n"); + for(a=1;a<=n;a++) + { + printf("i[%d]=",a); + scanf("%d",&i[a]); + } + for(a=1;ai[b+1]) + { + k=i[b]; + i[b]=i[b+1]; + i[b+1]=k; + } +for(a=1;a<=n;a++) +printf("%d\n",i[a]); + } + + +#include +int jc(int a) +{ +int b=1,i; +for(i=1;i<=a;i++) +b*=i; +return b; +} + void main() + { + int x,y; + printf("杈撳叆鏁存暟锛"); + scanf("%d",&x); + y=jc(x); + printf("jc=%d",y); + } + + +#include +main() +{ + int n; + printf("n鐨勫间负:"); + scanf("%d",&n); + int i,j,k; + int a[n]={0}; + for(i=1;i<=n;i++) + { + printf("a[%d]:",i); + scanf("%d",&a[i]); + } + for(i=1;i<=n-1;i++) + for(j=1;j +double zj(float a,float b,float c) +{ + float d; + if(a +main() +{ + int a,b,c,d; + printf(" *"); + for(a=1;a<=9;a++) + printf("%3d",a); + printf("\n"); + for(a=1;a<=9;a++); +{ +printf("%3d",a); +for(b=1;b<=a;b++) +{ +c=a*b; +printf("%3d",c); +} +printf("\n"); +} + +#include +main() +{ + int a; + for(a=1;a<+100;a++) + if(a%7==0||a%10==7) + printf("%d\n",a); + } } + + + #include +int main() +{ + int a; + printf("杈撳叆骞翠唤锛"); + scanf("%d",&a); + if(a%400==0||a%100!=0&&a%4==0) + printf("a涓洪棸骞"); + else + printf("a涓嶄负闂板勾"); +} From 70de7783724fd9337d721a1c8880e5155f56ea5e Mon Sep 17 00:00:00 2001 From: jinshayumi <791682161@QQ.COM> Date: Wed, 15 Mar 2017 21:46:34 +0800 Subject: [PATCH 03/39] hanoi --- hanoi | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 hanoi diff --git a/hanoi b/hanoi new file mode 100644 index 00000000..ca5f17b8 --- /dev/null +++ b/hanoi @@ -0,0 +1,18 @@ +#include +void move(int n,int x,int y,int z) +{ + if(n==1) + { + move(n-1,x,z,y); + printf("%c->%c\n",x,z); + move(n-1,y,x,z); + } +} +void main() +{ + int h; + printf("\ninputnumber:\n"); + scanf("%d",&h); + printf("the step to moving %2d diskes:\n",h); + move(h,'a','b','c'); +} From 5bb6bc323822e0ccde434d98f54fcb8d9bc6ee72 Mon Sep 17 00:00:00 2001 From: jinshayumi <791682161@QQ.COM> Date: Wed, 15 Mar 2017 22:22:24 +0800 Subject: [PATCH 04/39] hanoi --- practices/c/level1/hanoi | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 practices/c/level1/hanoi diff --git a/practices/c/level1/hanoi b/practices/c/level1/hanoi new file mode 100644 index 00000000..ca5f17b8 --- /dev/null +++ b/practices/c/level1/hanoi @@ -0,0 +1,18 @@ +#include +void move(int n,int x,int y,int z) +{ + if(n==1) + { + move(n-1,x,z,y); + printf("%c->%c\n",x,z); + move(n-1,y,x,z); + } +} +void main() +{ + int h; + printf("\ninputnumber:\n"); + scanf("%d",&h); + printf("the step to moving %2d diskes:\n",h); + move(h,'a','b','c'); +} From ae787802390c59a649432d5daf15657f463c928a Mon Sep 17 00:00:00 2001 From: jinshayumi <791682161@QQ.COM> Date: Mon, 27 Mar 2017 18:37:17 +0800 Subject: [PATCH 05/39] new level 1 --- practices/c/level1/new level 1 | 225 +++++++++++++++++++++++++++++++++ 1 file changed, 225 insertions(+) create mode 100644 practices/c/level1/new level 1 diff --git a/practices/c/level1/new level 1 b/practices/c/level1/new level 1 new file mode 100644 index 00000000..1e832730 --- /dev/null +++ b/practices/c/level1/new level 1 @@ -0,0 +1,225 @@ +#include +#include + +/* run this program using the console pauser or add your own getch, system("pause") or input loop */ + +int main(int argc, char *argv[]) +{ + + printf("add:1锛宒ecode:2锛"); + int choose; + scanf("%d",&choose); + if(choose==1) + { + char add[30],*a; + a=add; + printf("add锛"); + scanf("%s",add); + while(*a!='\0') + { + *a=*a+'B'-'m'; + a++; + } + printf("%s",add); + } + + else if(choose==2) + { + char decode[30],*b; + b=decode; + printf("decode锛"); + scanf("%s",decode); + while(*b!='\0') + { + *b=*b+'m'-'B'; + b++; + } + printf("%s",decode); + } + + else + { + printf("error"); + } + return 0; +} + + + +#include +int main() +{ + int life,tn,qn,ds,son; + printf("age may be锛"); + for(life=1;life++;life<=100) + { + tn=life/6; + qn=life/12; + ds=life/7; + son=life/2; + + if(life==tn+qn+ds+5+son+4&&life%84==0) + { + printf("%d",life); + } + } +} + + + +#include +int main() +{ + int a,b,c; + printf("primes from 2-1000锛2\t"); + for(a=3;a<=1000;a++) + { + c=0; + for(b=2;b +int sushu(int a) +{ + int b, c=0; + for(b=2;b + +void move(int n,int x,int y,int z) +{ + if(n==1) + { + printf("%c->%c\n",x,z); + } + else + { + move(n-1,x,z,y); + printf("%c->%c\n",x,z); + move(n-1,y,x,z); + } +} +void main() +{ + int h; + printf("\ninputnumber:\n"); + scanf("%d",&h); + printf("the step to moving %2d diskes:\n",h); + move(h,'a','b','c'); +} + + + +#include +int main() +{ + int a,i,b; + b=0; + printf("print the letter锛"); + scanf("%d",&a); + for(i=2;i +int main() +{ + int shuixianhua,bai,shi,ge; + printf("the narcissus锛"); + for(shuixianhua=100;shuixianhua<1000;shuixianhua++) + { + bai=shuixianhua/100; + shi=(shuixianhua-100*bai)/10; + ge=shuixianhua%10; + + if(shuixianhua==ge*ge*ge+shi*shi*shi+bai*bai*bai) + { + printf("%d\t",shuixianhua); + } + } +} + + + +#include +#include + +int main() +{ + int i,j; + for (i=0;i<31;i++) + { + system("cls"); + for(j=0;j= 0;i--) + { + system("cls"); + for(j=0; j Date: Tue, 28 Mar 2017 18:20:20 +0800 Subject: [PATCH 06/39] changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 鏄ㄥぉ鏀逛簡 濂藉儚娌′紶涓婂幓杩樻槸浼犻敊浜嗐傘 --- practices/c/level1/add and decode.c | 45 +++++++++++++++++++++++++++++ practices/c/level1/age.c | 18 ++++++++++++ practices/c/level1/all primes.c | 19 ++++++++++++ practices/c/level1/goldbach.c | 33 +++++++++++++++++++++ practices/c/level1/hanoi.c | 23 +++++++++++++++ practices/c/level1/is prime.c | 21 ++++++++++++++ practices/c/level1/narcissus.c | 17 +++++++++++ practices/c/level1/running a.c | 28 ++++++++++++++++++ 8 files changed, 204 insertions(+) create mode 100644 practices/c/level1/add and decode.c create mode 100644 practices/c/level1/age.c create mode 100644 practices/c/level1/all primes.c create mode 100644 practices/c/level1/goldbach.c create mode 100644 practices/c/level1/hanoi.c create mode 100644 practices/c/level1/is prime.c create mode 100644 practices/c/level1/narcissus.c create mode 100644 practices/c/level1/running a.c diff --git a/practices/c/level1/add and decode.c b/practices/c/level1/add and decode.c new file mode 100644 index 00000000..6d5d8d7d --- /dev/null +++ b/practices/c/level1/add and decode.c @@ -0,0 +1,45 @@ +#include +#include + +/* run this program using the console pauser or add your own getch, system("pause") or input loop */ + +int main(int argc, char *argv[]) +{ + + printf("add:1,decode:2:"); + int choose; + scanf("%d",&choose); + if(choose==1) + { + char add[30],*a; + a=add; + printf("add:"); + scanf("%s",add); + while(*a!='\0') + { + *a=*a+'B'-'m'; + a++; + } + printf("%s",add); + } + + else if(choose==2) + { + char decode[30],*b; + b=decode; + printf("decode:"); + scanf("%s",decode); + while(*b!='\0') + { + *b=*b+'m'-'B'; + b++; + } + printf("%s",decode); + } + + else + { + printf("error"); + } + return 0; +} diff --git a/practices/c/level1/age.c b/practices/c/level1/age.c new file mode 100644 index 00000000..f8008525 --- /dev/null +++ b/practices/c/level1/age.c @@ -0,0 +1,18 @@ +#include +int main() +{ + int life,tn,qn,ds,son; + printf("age may be:"); + for(life=1;life++;life<=100) + { + tn=life/6; + qn=life/12; + ds=life/7; + son=life/2; + + if(life==tn+qn+ds+5+son+4&&life%84==0) + { + printf("%d",life); + } + } +} diff --git a/practices/c/level1/all primes.c b/practices/c/level1/all primes.c new file mode 100644 index 00000000..021c05b2 --- /dev/null +++ b/practices/c/level1/all primes.c @@ -0,0 +1,19 @@ +#include +int main() +{ + int a,b,c; + printf("primes from 2-1000:2\t"); + for(a=3;a<=1000;a++) + { + c=0; + for(b=2;b +int sushu(int a) +{ + int b, c=0; + for(b=2;b + +void move(int n,int x,int y,int z) +{ + if(n==1) + { + printf("%c->%c\n",x,z); + } + else + { + move(n-1,x,z,y); + printf("%c->%c\n",x,z); + move(n-1,y,x,z); + } +} +void main() +{ + int h; + printf("\ninputnumber:\n"); + scanf("%d",&h); + printf("the step to moving %2d diskes:\n",h); + move(h,'a','b','c'); +} diff --git a/practices/c/level1/is prime.c b/practices/c/level1/is prime.c new file mode 100644 index 00000000..db926e30 --- /dev/null +++ b/practices/c/level1/is prime.c @@ -0,0 +1,21 @@ +#include +int main() +{ + int a,i,b; + b=0; + printf("print the letter:"); + scanf("%d",&a); + for(i=2;i +int main() +{ + int shuixianhua,bai,shi,ge; + printf("the narcissus:"); + for(shuixianhua=100;shuixianhua<1000;shuixianhua++) + { + bai=shuixianhua/100; + shi=(shuixianhua-100*bai)/10; + ge=shuixianhua%10; + + if(shuixianhua==ge*ge*ge+shi*shi*shi+bai*bai*bai) + { + printf("%d\t",shuixianhua); + } + } +} diff --git a/practices/c/level1/running a.c b/practices/c/level1/running a.c new file mode 100644 index 00000000..648e83b9 --- /dev/null +++ b/practices/c/level1/running a.c @@ -0,0 +1,28 @@ +#include +#include + +int main() +{ + int i,j; + for (i=0;i<31;i++) + { + system("cls"); + for(j=0;j= 0;i--) + { + system("cls"); + for(j=0; j Date: Tue, 28 Mar 2017 19:02:38 +0800 Subject: [PATCH 07/39] =?UTF-8?q?Delete=201=E4=B8=87=E4=BD=A0=E5=A5=BD.c?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../c/level0/1\344\270\207\344\275\240\345\245\275.c" | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 "practices/c/level0/1\344\270\207\344\275\240\345\245\275.c" diff --git "a/practices/c/level0/1\344\270\207\344\275\240\345\245\275.c" "b/practices/c/level0/1\344\270\207\344\275\240\345\245\275.c" deleted file mode 100644 index a1baf142..00000000 --- "a/practices/c/level0/1\344\270\207\344\275\240\345\245\275.c" +++ /dev/null @@ -1,7 +0,0 @@ -#include -main() -{ - int i; - for(i=1;i<=10000;i++) - printf("hello "); - } From 6d854d576eec02c8722b281e1c151b79abe0ed32 Mon Sep 17 00:00:00 2001 From: jinshayumi <791682161@QQ.COM> Date: Tue, 28 Mar 2017 19:02:50 +0800 Subject: [PATCH 08/39] =?UTF-8?q?Delete=202=E5=88=B0100=E5=81=B6=E6=95=B0.?= =?UTF-8?q?c?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../c/level0/2\345\210\260100\345\201\266\346\225\260.c" | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 "practices/c/level0/2\345\210\260100\345\201\266\346\225\260.c" diff --git "a/practices/c/level0/2\345\210\260100\345\201\266\346\225\260.c" "b/practices/c/level0/2\345\210\260100\345\201\266\346\225\260.c" deleted file mode 100644 index 42c9e635..00000000 --- "a/practices/c/level0/2\345\210\260100\345\201\266\346\225\260.c" +++ /dev/null @@ -1,7 +0,0 @@ -#include -main() -{ - int a; - for(a=2;a<=100;a=a+2) - printf("%d ",a); - } From 4e600022ce15d440cc12af05e92a02b725a64735 Mon Sep 17 00:00:00 2001 From: jinshayumi <791682161@QQ.COM> Date: Tue, 28 Mar 2017 19:03:48 +0800 Subject: [PATCH 09/39] =?UTF-8?q?Delete=203=E4=B8=AA=E6=95=B0.c?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../c/level0/3\344\270\252\346\225\260.c" | 21 ------------------- 1 file changed, 21 deletions(-) delete mode 100644 "practices/c/level0/3\344\270\252\346\225\260.c" diff --git "a/practices/c/level0/3\344\270\252\346\225\260.c" "b/practices/c/level0/3\344\270\252\346\225\260.c" deleted file mode 100644 index 688723f4..00000000 --- "a/practices/c/level0/3\344\270\252\346\225\260.c" +++ /dev/null @@ -1,21 +0,0 @@ -#include -void main() -{ - int a,b,c; - printf("输入三个数:"); - scanf("%d %d %d",&a,&b,&c); - if(a>b) - { - if(a>c) - printf("最大的为%d",a); - else - printf("最大的为%d",c); - } - else - { - if(b Date: Tue, 28 Mar 2017 19:04:08 +0800 Subject: [PATCH 10/39] =?UTF-8?q?Delete=203=E6=95=B4=E9=99=A45=E4=B8=8D?= =?UTF-8?q?=E6=95=B4=E9=99=A4.c?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...351\231\2445\344\270\215\346\225\264\351\231\244.c" | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 "practices/c/level0/3\346\225\264\351\231\2445\344\270\215\346\225\264\351\231\244.c" diff --git "a/practices/c/level0/3\346\225\264\351\231\2445\344\270\215\346\225\264\351\231\244.c" "b/practices/c/level0/3\346\225\264\351\231\2445\344\270\215\346\225\264\351\231\244.c" deleted file mode 100644 index b683dd1d..00000000 --- "a/practices/c/level0/3\346\225\264\351\231\2445\344\270\215\346\225\264\351\231\244.c" +++ /dev/null @@ -1,10 +0,0 @@ -#include -main() -{ - int a; - for(a=1;a<=100;a++) - { - if(a%3==0&&a%5!=0) - printf("%d\n",a); - } -} From 6fbf10676078d22baba509508449d9ecde4ac9ae Mon Sep 17 00:00:00 2001 From: jinshayumi <791682161@QQ.COM> Date: Tue, 28 Mar 2017 19:07:06 +0800 Subject: [PATCH 11/39] =?UTF-8?q?Delete=205=E4=B8=AA=E6=95=B0.c?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "practices/c/level0/5\344\270\252\346\225\260.c" | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 "practices/c/level0/5\344\270\252\346\225\260.c" diff --git "a/practices/c/level0/5\344\270\252\346\225\260.c" "b/practices/c/level0/5\344\270\252\346\225\260.c" deleted file mode 100644 index 5e155522..00000000 --- "a/practices/c/level0/5\344\270\252\346\225\260.c" +++ /dev/null @@ -1,16 +0,0 @@ -#include -main() -{ - int a[5]; - printf("输入5个数"); - int i,b; - for(i=1;i<=5;i++) - { - scanf("%d",&a[i]); - } - printf("没有出现的数为"); - for(b=0;b<=9;b++) - if(b!=a[1]&&b!=a[2]&&b!=a[3]&&b!=a[4]&&b!=a[5]) - printf("%d",a[i]); - -} From cc3cbb6c5edfdaa691feebc0240bbfb2400dac5a Mon Sep 17 00:00:00 2001 From: jinshayumi <791682161@QQ.COM> Date: Tue, 28 Mar 2017 19:07:16 +0800 Subject: [PATCH 12/39] =?UTF-8?q?Delete=205=E4=B8=AA=E6=AF=94=E5=A4=A7?= =?UTF-8?q?=E5=B0=8F.c?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...252\346\257\224\345\244\247\345\260\217.c" | 23 ------------------- 1 file changed, 23 deletions(-) delete mode 100644 "practices/c/level0/5\344\270\252\346\257\224\345\244\247\345\260\217.c" diff --git "a/practices/c/level0/5\344\270\252\346\257\224\345\244\247\345\260\217.c" "b/practices/c/level0/5\344\270\252\346\257\224\345\244\247\345\260\217.c" deleted file mode 100644 index 4febba14..00000000 --- "a/practices/c/level0/5\344\270\252\346\257\224\345\244\247\345\260\217.c" +++ /dev/null @@ -1,23 +0,0 @@ -#include -void main() -{ - int a,b,k; - const n=5; - int i[n]; - printf("请输入5个0-9的数:\n"); - for(a=1;a<=n;a++) - { - printf("i[%d]=",a); - scanf("%d",&i[a]); - } - for(a=1;ai[b+1]) - { - k=i[b]; - i[b]=i[b+1]; - i[b+1]=k; - } - for(a=1;a<=n;a++) - printf("%d\n",i[a]); - } From 357654f109ab53396688d168d1e943181d8942fa Mon Sep 17 00:00:00 2001 From: jinshayumi <791682161@QQ.COM> Date: Tue, 28 Mar 2017 19:07:24 +0800 Subject: [PATCH 13/39] Delete 99.c --- practices/c/level0/99.c | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100644 practices/c/level0/99.c diff --git a/practices/c/level0/99.c b/practices/c/level0/99.c deleted file mode 100644 index 3380b86c..00000000 --- a/practices/c/level0/99.c +++ /dev/null @@ -1,22 +0,0 @@ -#include -int main() -{ - int a,b,c; - printf(" *"); - for(a=1;a<=9;a++) - { - printf("%4d",a); - } - printf("\n"); - for(a=1;a<=9;a++) - { - printf("%4d",a); - for(b=1;b<=a;b++) - { - c=a*b; - printf("%4d",c); - } - printf("\n"); - } - -} From 572c7959610a2c018c9cf0f1ee0494c579889e68 Mon Sep 17 00:00:00 2001 From: jinshayumi <791682161@QQ.COM> Date: Tue, 28 Mar 2017 19:07:34 +0800 Subject: [PATCH 14/39] Delete JCC.c --- practices/c/level0/JCC.c | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 practices/c/level0/JCC.c diff --git a/practices/c/level0/JCC.c b/practices/c/level0/JCC.c deleted file mode 100644 index ae23b655..00000000 --- a/practices/c/level0/JCC.c +++ /dev/null @@ -1,17 +0,0 @@ -#include -int jc(int a) -{ - int b=1,i; - for(i=1;i<=a;i++) - b*=i; - return b; - } - void main() - { - int x,y; - printf("输入整数:"); - scanf("%d",&x); - y=jc(x); - printf("jc=%d",y); - } - From 5eb085c80a94807f63044bee66db43e1d1a405c3 Mon Sep 17 00:00:00 2001 From: jinshayumi <791682161@QQ.COM> Date: Tue, 28 Mar 2017 19:07:46 +0800 Subject: [PATCH 15/39] =?UTF-8?q?Delete=20L0=EF=BC=8CL1PART?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "practices/c/level0/L0\357\274\214L1PART" | 204 ---------------------- 1 file changed, 204 deletions(-) delete mode 100644 "practices/c/level0/L0\357\274\214L1PART" diff --git "a/practices/c/level0/L0\357\274\214L1PART" "b/practices/c/level0/L0\357\274\214L1PART" deleted file mode 100644 index 3dadbfa1..00000000 --- "a/practices/c/level0/L0\357\274\214L1PART" +++ /dev/null @@ -1,204 +0,0 @@ -#include -main() -{ - int i; - for(i=1;i<=10000;i++) - printf("hello "); - } - - - -#include -main() -{ - int a; - for(a=2;a<=100;a=a+2) - printf("%d ",a); - } - - - - #include -void main() -{ - int a,b,c; - printf("杈撳叆涓変釜鏁帮細"); - scanf("%d %d %d",&a,&b,&c); - if(a>b) - { - if(a>c) - printf("鏈澶х殑涓%d",a); - else - printf("鏈澶х殑涓%d",c); - } - else - { - if(b -main() -{ - int a; - for(a=1;a<=100;a++) - { - if(a%3==0&&a%5!=0) - printf("%d\n",a); - } -} - - -#include -void main() -{ - int a,b,k; - const n=5; - int i[n]; - printf("璇疯緭鍏5涓0-9鐨勬暟锛歕n"); - for(a=1;a<=n;a++) - { - printf("i[%d]=",a); - scanf("%d",&i[a]); - } - for(a=1;ai[b+1]) - { - k=i[b]; - i[b]=i[b+1]; - i[b+1]=k; - } -for(a=1;a<=n;a++) -printf("%d\n",i[a]); - } - - -#include -int jc(int a) -{ -int b=1,i; -for(i=1;i<=a;i++) -b*=i; -return b; -} - void main() - { - int x,y; - printf("杈撳叆鏁存暟锛"); - scanf("%d",&x); - y=jc(x); - printf("jc=%d",y); - } - - -#include -main() -{ - int n; - printf("n鐨勫间负:"); - scanf("%d",&n); - int i,j,k; - int a[n]={0}; - for(i=1;i<=n;i++) - { - printf("a[%d]:",i); - scanf("%d",&a[i]); - } - for(i=1;i<=n-1;i++) - for(j=1;j -double zj(float a,float b,float c) -{ - float d; - if(a -main() -{ - int a,b,c,d; - printf(" *"); - for(a=1;a<=9;a++) - printf("%3d",a); - printf("\n"); - for(a=1;a<=9;a++); -{ -printf("%3d",a); -for(b=1;b<=a;b++) -{ -c=a*b; -printf("%3d",c); -} -printf("\n"); -} - -#include -main() -{ - int a; - for(a=1;a<+100;a++) - if(a%7==0||a%10==7) - printf("%d\n",a); - } } - - - #include -int main() -{ - int a; - printf("杈撳叆骞翠唤锛"); - scanf("%d",&a); - if(a%400==0||a%100!=0&&a%4==0) - printf("a涓洪棸骞"); - else - printf("a涓嶄负闂板勾"); -} From 4ad7c7095371ed999d4ec5fea6e5d5de7ce39dd3 Mon Sep 17 00:00:00 2001 From: jinshayumi <791682161@QQ.COM> Date: Tue, 28 Mar 2017 19:08:19 +0800 Subject: [PATCH 16/39] Delete hello.c --- practices/c/level0/hello.c | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 practices/c/level0/hello.c diff --git a/practices/c/level0/hello.c b/practices/c/level0/hello.c deleted file mode 100644 index 41e35e31..00000000 --- a/practices/c/level0/hello.c +++ /dev/null @@ -1,5 +0,0 @@ -#include -main() -{ -printf("hello world,I am Guohu!"); -} From 43597b71395f4112630b4f548a28eb333198fc20 Mon Sep 17 00:00:00 2001 From: jinshayumi <791682161@QQ.COM> Date: Tue, 28 Mar 2017 19:08:26 +0800 Subject: [PATCH 17/39] =?UTF-8?q?Delete=20n=E4=B8=AA=E5=A4=A7=E5=B0=8F.c?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../n\344\270\252\345\244\247\345\260\217.c" | 25 ------------------- 1 file changed, 25 deletions(-) delete mode 100644 "practices/c/level0/n\344\270\252\345\244\247\345\260\217.c" diff --git "a/practices/c/level0/n\344\270\252\345\244\247\345\260\217.c" "b/practices/c/level0/n\344\270\252\345\244\247\345\260\217.c" deleted file mode 100644 index 81b3e8e6..00000000 --- "a/practices/c/level0/n\344\270\252\345\244\247\345\260\217.c" +++ /dev/null @@ -1,25 +0,0 @@ -#include -main() -{ - int n; - printf("n的值为:"); - scanf("%d",&n); - int i,j,k; - int a[n]={0}; - for(i=1;i<=n;i++) - { - printf("a[%d]:",i); - scanf("%d",&a[i]); - } - for(i=1;i<=n-1;i++) - for(j=1;j Date: Tue, 28 Mar 2017 19:08:34 +0800 Subject: [PATCH 18/39] =?UTF-8?q?Delete=20n=E4=B8=AA=E6=95=B0.c?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../c/level0/n\344\270\252\346\225\260.c" | 22 ------------------- 1 file changed, 22 deletions(-) delete mode 100644 "practices/c/level0/n\344\270\252\346\225\260.c" diff --git "a/practices/c/level0/n\344\270\252\346\225\260.c" "b/practices/c/level0/n\344\270\252\346\225\260.c" deleted file mode 100644 index deb76253..00000000 --- "a/practices/c/level0/n\344\270\252\346\225\260.c" +++ /dev/null @@ -1,22 +0,0 @@ -#include -int main() -{ - int m,n,a,i; - m=1; - - printf("n的值为:"); - scanf("%d",&n); - printf("输入n个数"); - - for(i=1;i<=n;i++) - { - scanf("%d",&a); - printf("\n"); - if(a>m) - { - m=a; - - } - } - printf("最大的数为%d",m); - } From fcd606b0a408247123260e557919003599bcdd73 Mon Sep 17 00:00:00 2001 From: jinshayumi <791682161@QQ.COM> Date: Tue, 28 Mar 2017 19:08:42 +0800 Subject: [PATCH 19/39] Delete zj.c --- practices/c/level0/zj.c | 36 ------------------------------------ 1 file changed, 36 deletions(-) delete mode 100644 practices/c/level0/zj.c diff --git a/practices/c/level0/zj.c b/practices/c/level0/zj.c deleted file mode 100644 index 0c118512..00000000 --- a/practices/c/level0/zj.c +++ /dev/null @@ -1,36 +0,0 @@ -#include -double zj(float a,float b,float c) -{ - float d; - if(a Date: Tue, 28 Mar 2017 19:08:56 +0800 Subject: [PATCH 20/39] =?UTF-8?q?Delete=20=E5=A5=87=E5=81=B6=2013.c?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../c/level0/\345\245\207\345\201\266 13.c" | 26 ------------------- 1 file changed, 26 deletions(-) delete mode 100644 "practices/c/level0/\345\245\207\345\201\266 13.c" diff --git "a/practices/c/level0/\345\245\207\345\201\266 13.c" "b/practices/c/level0/\345\245\207\345\201\266 13.c" deleted file mode 100644 index f620f22a..00000000 --- "a/practices/c/level0/\345\245\207\345\201\266 13.c" +++ /dev/null @@ -1,26 +0,0 @@ -#include -main() -{ - int a; - printf("输入a的值:"); - scanf("%d",&a); - - if(a>0) - printf("a为正数"); - else if(a==0) - printf("a为0"); - else - printf("a为负数"); - printf("\n"); - - if(a%2==0) - printf("a为偶数"); - else - printf("a为奇数"); - printf("\n"); - - if(a%13==0) - printf("a为13倍数"); - else - printf("a不为13倍数"); -} From 8ce52ed4383e28d85d3ae4ccaa4da19bbe094f0a Mon Sep 17 00:00:00 2001 From: jinshayumi <791682161@QQ.COM> Date: Tue, 28 Mar 2017 19:09:06 +0800 Subject: [PATCH 21/39] =?UTF-8?q?Delete=20=E8=B7=9F7=E6=9C=89=E5=85=B3.c?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../c/level0/\350\267\2377\346\234\211\345\205\263.c" | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 "practices/c/level0/\350\267\2377\346\234\211\345\205\263.c" diff --git "a/practices/c/level0/\350\267\2377\346\234\211\345\205\263.c" "b/practices/c/level0/\350\267\2377\346\234\211\345\205\263.c" deleted file mode 100644 index d2c57b11..00000000 --- "a/practices/c/level0/\350\267\2377\346\234\211\345\205\263.c" +++ /dev/null @@ -1,8 +0,0 @@ -#include -main() -{ - int a; - for(a=1;a<+100;a++) - if(a%7==0||a%10==7) - printf("%d\n",a); - } From 3851542a7474a1ba980fa046f04ac0c10899debd Mon Sep 17 00:00:00 2001 From: jinshayumi <791682161@QQ.COM> Date: Tue, 28 Mar 2017 19:09:15 +0800 Subject: [PATCH 22/39] =?UTF-8?q?Delete=20=E9=97=B0=E5=B9=B4.c?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "practices/c/level0/\351\227\260\345\271\264.c" | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 "practices/c/level0/\351\227\260\345\271\264.c" diff --git "a/practices/c/level0/\351\227\260\345\271\264.c" "b/practices/c/level0/\351\227\260\345\271\264.c" deleted file mode 100644 index cfeff527..00000000 --- "a/practices/c/level0/\351\227\260\345\271\264.c" +++ /dev/null @@ -1,11 +0,0 @@ -#include -int main() -{ - int a; - printf("输入年份:"); - scanf("%d",&a); - if(a%400==0||a%100!=0&&a%4==0) - printf("a为闰年"); - else - printf("a不为闰年"); -} From 9b4a5b87c0e8360661539a3bf738333167d195e0 Mon Sep 17 00:00:00 2001 From: jinshayumi <791682161@QQ.COM> Date: Tue, 28 Mar 2017 19:10:06 +0800 Subject: [PATCH 23/39] new level 0 --- practices/c/level0/10000 he.c | 10 +++++++++ practices/c/level0/2.c | 10 +++++++++ practices/c/level0/3 and 5.c | 10 +++++++++ practices/c/level0/3 num.c | 30 +++++++++++++++++++++++++ practices/c/level0/5 num.c | 20 +++++++++++++++++ practices/c/level0/99.c | 23 +++++++++++++++++++ practices/c/level0/about 7.c | 13 +++++++++++ practices/c/level0/compare 5.c | 24 ++++++++++++++++++++ practices/c/level0/jiecheng.c | 21 +++++++++++++++++ practices/c/level0/nixu.c | 39 ++++++++++++++++++++++++++++++++ practices/c/level0/runnian.c | 15 +++++++++++++ practices/c/level0/zhijiao.c | 41 ++++++++++++++++++++++++++++++++++ 12 files changed, 256 insertions(+) create mode 100644 practices/c/level0/10000 he.c create mode 100644 practices/c/level0/2.c create mode 100644 practices/c/level0/3 and 5.c create mode 100644 practices/c/level0/3 num.c create mode 100644 practices/c/level0/5 num.c create mode 100644 practices/c/level0/99.c create mode 100644 practices/c/level0/about 7.c create mode 100644 practices/c/level0/compare 5.c create mode 100644 practices/c/level0/jiecheng.c create mode 100644 practices/c/level0/nixu.c create mode 100644 practices/c/level0/runnian.c create mode 100644 practices/c/level0/zhijiao.c diff --git a/practices/c/level0/10000 he.c b/practices/c/level0/10000 he.c new file mode 100644 index 00000000..df7dfdca --- /dev/null +++ b/practices/c/level0/10000 he.c @@ -0,0 +1,10 @@ +#include + +void main() +{ + int i; + for(i=1;i<=10000;i++) + { + printf("hello "); + } + } diff --git a/practices/c/level0/2.c b/practices/c/level0/2.c new file mode 100644 index 00000000..607aa76f --- /dev/null +++ b/practices/c/level0/2.c @@ -0,0 +1,10 @@ +#include + +void main() +{ + int a; + for(a=2;a<=100;a=a+2) + { + printf("%d ",a); + } + } diff --git a/practices/c/level0/3 and 5.c b/practices/c/level0/3 and 5.c new file mode 100644 index 00000000..66df4b65 --- /dev/null +++ b/practices/c/level0/3 and 5.c @@ -0,0 +1,10 @@ +#include +void main() +{ + int a; + for(a=1;a<=100;a++) + { + if(a%3==0&&a%5!=0) + printf("%d\n",a); + } +} diff --git a/practices/c/level0/3 num.c b/practices/c/level0/3 num.c new file mode 100644 index 00000000..010a04e7 --- /dev/null +++ b/practices/c/level0/3 num.c @@ -0,0 +1,30 @@ +#include + +void main() +{ + int a,b,c; + printf("输入三个数:"); + scanf("%d %d %d",&a,&b,&c); + if(a>b) + { + if(a>c) + { + printf("最大的为%d",a); + } + else + { + printf("最大的为%d",c); + } + } + else + { + if(b + +void main() +{ + int a[5]; + printf("输入5个数"); + int i,b; + for(i=1;i<=5;i++) + { + scanf("%d",&a[i]); + } + printf("没有出现的数为"); + for(b=0;b<=9;b++) + { + if(b!=a[1]&&b!=a[2]&&b!=a[3]&&b!=a[4]&&b!=a[5]) + { + printf("%d",a[i]); + } + } +} diff --git a/practices/c/level0/99.c b/practices/c/level0/99.c new file mode 100644 index 00000000..8dc1780e --- /dev/null +++ b/practices/c/level0/99.c @@ -0,0 +1,23 @@ +#include + +void main() +{ + int a,b,c; + printf(" *"); + for(a=1;a<=9;a++) + { + printf("%4d",a); + } + printf("\n"); + for(a=1;a<=9;a++) + { + printf("%4d",a); + for(b=1;b<=a;b++) + { + c=a*b; + printf("%4d",c); + } + printf("\n"); + } + +} diff --git a/practices/c/level0/about 7.c b/practices/c/level0/about 7.c new file mode 100644 index 00000000..83c65543 --- /dev/null +++ b/practices/c/level0/about 7.c @@ -0,0 +1,13 @@ +#include + +void main() +{ + int a; + for(a=1;a<+100;a++) + { + if(a%7==0||a%10==7) + { + printf("%d\n",a); + } + } + } diff --git a/practices/c/level0/compare 5.c b/practices/c/level0/compare 5.c new file mode 100644 index 00000000..acbd14af --- /dev/null +++ b/practices/c/level0/compare 5.c @@ -0,0 +1,24 @@ +#include + +void main() +{ + int a,b,k; + const n=5; + int i[n]; + printf("输入5个数:\n"); + for(a=1;a<=n;a++) + { + printf("i[%d]=",a); + scanf("%d",&i[a]); + } + for(a=1;ai[b+1]) + { + k=i[b]; + i[b]=i[b+1]; + i[b+1]=k; + } + for(a=1;a<=n;a++) + printf("%d\n",i[a]); + } diff --git a/practices/c/level0/jiecheng.c b/practices/c/level0/jiecheng.c new file mode 100644 index 00000000..d2ac9e2a --- /dev/null +++ b/practices/c/level0/jiecheng.c @@ -0,0 +1,21 @@ +#include + +int jc(int a) +{ + int b=1,i; + for(i=1;i<=a;i++) + { + b*=i; + } + return b; + } +void main() + +{ + int x,y; + printf("ê?è???êy£o"); + scanf("%d",&x); + y=jc(x); + printf("jc=%d",y); +} + diff --git a/practices/c/level0/nixu.c b/practices/c/level0/nixu.c new file mode 100644 index 00000000..99e5324b --- /dev/null +++ b/practices/c/level0/nixu.c @@ -0,0 +1,39 @@ +#include +#include + +int main() +{ + int n=0; + printf("n是:"); + scanf("%d",&n); + int* p; + int i=0; + int m=0; + p=(int*)malloc(n*sizeof(int)); + printf("输入数据:\n"); + for(i=0;i +int main() +{ + int a; + printf("输入年份:"); + scanf("%d",&a); + if(a%400==0||a%100!=0&&a%4==0) + { + printf("a为闰年"); + } + else + { + printf("a不为闰年"); + } +} diff --git a/practices/c/level0/zhijiao.c b/practices/c/level0/zhijiao.c new file mode 100644 index 00000000..e124d1ef --- /dev/null +++ b/practices/c/level0/zhijiao.c @@ -0,0 +1,41 @@ +#include + +double zj(float a,float b,float c) +{ + float d; + if(a Date: Wed, 5 Apr 2017 23:03:55 +0800 Subject: [PATCH 24/39] maze --- practices/c/level1/maze | 138 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100644 practices/c/level1/maze diff --git a/practices/c/level1/maze b/practices/c/level1/maze new file mode 100644 index 00000000..4461aead --- /dev/null +++ b/practices/c/level1/maze @@ -0,0 +1,138 @@ +#include +#include + +char map[6][6]; +int X,Y,M,N; + +void move(char i) +{ + if(i=='w') + { + if(map[M-1][N]!='*') + { + map[M][N]=' '; + M--; + map[M][N]='A'; + } + } + else if(i=='s') + { + if(map[M+1][N]!='*') + { + map[M][N]=' '; + M++; + map[M][N]='A'; + } + } + else if(i=='a') + { + if(map[M][N-1]!='*') + { + map[M][N]=' '; + N--; + map[M][N]='A'; + } + } + else if(i=='d') + { + if(map[M][N+1]!='*') + { + map[M][N]=' '; + N++; + map[M][N]='A'; + } + } + +} + +void main() +{ + for(X=0;X<6;X++) + { + for(Y=0;Y<6;Y++) + { + map[X][Y]=' '; + } + } + M=0,N=1; + map[M][N]='A'; + + for(Y=0;Y<6;Y++) + { + if(Y!=1) + { + map[0][Y]='*'; + } + } + + for(Y=0;Y<6;Y++) + { + if(Y!=1&&Y!=2) + { + map[1][Y]='*'; + } + } + + for(Y=0;Y<6;Y++) + { + if(Y!=2&&Y!=3) + { + map[2][Y]='*'; + } + } + + for(Y=0;Y<6;Y++) + { + if(Y!=1&&Y!=2) + { + map[3][Y]='*'; + } + } + + + + + for(Y=0;Y<6;Y++) + { + if(Y!=2&&Y!=3) + { + map[4][Y]='*'; + } + } + + for(Y=0;Y<6;Y++) + { + if(Y!=3) + { + map[5][Y]='*'; + } + } + map[5][3]='x'; + + int m,n; + char i; + for(m=0;m<6;m++) + { + for(n=0;n<6;n++) + { + printf("%c",map[m][n]); + } + printf("\n"); + } + while(map[5][3]!='A') + { + scanf("%c",&i); + move(i); + system("cls"); + for(m=0;m<6;m++) + { + for(n=0;n<6;n++) + { + printf("%c",map[m][n]); + } + printf("\n"); + } + + } + printf("nice!"); +} From 866acb7aa609dd0d92eb0422b4276b9c73760d40 Mon Sep 17 00:00:00 2001 From: jinshayumi <791682161@QQ.COM> Date: Mon, 22 May 2017 21:02:54 +0800 Subject: [PATCH 25/39] fighter main main --- practices/cpp/level1/fighter main | 127 ++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 practices/cpp/level1/fighter main diff --git a/practices/cpp/level1/fighter main b/practices/cpp/level1/fighter main new file mode 100644 index 00000000..838e58aa --- /dev/null +++ b/practices/cpp/level1/fighter main @@ -0,0 +1,127 @@ +#include +#include +#include "music.h" +#include "plane.h" + + +void move(sf::Sprite *thing) +{ + if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left)) + { + thing->move(-5,0); + } + if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right)) + { + thing->move(5,0); + } + if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up)) + { + thing->move(0,-5); + } + if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down)) + { + thing->move(0,5); + } +} + + + +int main() +{ + + sf::RenderWindow window(sf::VideoMode(1000,800), "play plane"); + + + + //闊充箰 + Music mymusic; + mymusic.play(); + + //鑳屾櫙 + sf::Texture a; + sf::Sprite b; + a.loadFromFile("back.png"); + b.setTexture(a); + + //椋炴満 + sf::Texture texture; + sf::Sprite self; + texture.loadFromFile("plane.png"); + self.setTexture(texture); + + //瀛愬脊 + Bullet mybullet[200]; + + //鍒濆浣嶇疆 + self.setOrigin(50,50); + self.setPosition(500,750); + + while (window.isOpen()) + { + sf::Event event; + while (window.pollEvent(event)) + { + if (event.type == sf::Event::Closed) + { + window.close(); + } + //鍔ㄩ鏈 + if(self.getPosition().x>42&&self.getPosition().x<958&&self.getPosition().y>52&&self.getPosition().y<800) + { + move(&self); + } + + //鎵撳瓙寮 + if (sf::Keyboard::isKeyPressed(sf::Keyboard::Space)) + { + for(int i=0;i<200;i++) + { + if(mybullet[i].statement==0) + { + mybullet[i].convex.setPosition(self.getPosition()); + mybullet[i].convex.move(0,-50); + mybullet[i].convex.move(-13,0); + mybullet[i].statement=1; + break; + } + } + + + } + + } + + + + + for(int i=0;i<200;i++) + { + if(mybullet[i].statement==1) + { + mybullet[i].convex.move(0,-2); + } + if(mybullet[i].convex.getPosition().y<-20) + { + mybullet[i].statement=0; + } + + } + + window.clear(); + window.draw(b); + window.draw(self); + + for(int i=0;i<200;i++) + { + if(mybullet[i].statement==1) + { + window.draw(mybullet[i].convex); + } + + } + window.display(); + } + + + return 0; +} From 4009b32ebc44596223bca5c850a64ddb5be677a9 Mon Sep 17 00:00:00 2001 From: jinshayumi <791682161@QQ.COM> Date: Mon, 22 May 2017 21:07:22 +0800 Subject: [PATCH 26/39] Create fighter music --- practices/cpp/level1/fighter music | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 practices/cpp/level1/fighter music diff --git a/practices/cpp/level1/fighter music b/practices/cpp/level1/fighter music new file mode 100644 index 00000000..2d2931cb --- /dev/null +++ b/practices/cpp/level1/fighter music @@ -0,0 +1,17 @@ +#include +#include + +class Music +{ + public: + sf::Music music; + int play() + { + if (!music.openFromFile("music.ogg")) + { + return -1; + } + music.play(); + } + +}; From b96672c211f9500afa5658d9c500c2a2865456b1 Mon Sep 17 00:00:00 2001 From: jinshayumi <791682161@QQ.COM> Date: Mon, 22 May 2017 21:08:02 +0800 Subject: [PATCH 27/39] Create fighter bullet --- practices/cpp/level1/fighter bullet | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 practices/cpp/level1/fighter bullet diff --git a/practices/cpp/level1/fighter bullet b/practices/cpp/level1/fighter bullet new file mode 100644 index 00000000..06e866d9 --- /dev/null +++ b/practices/cpp/level1/fighter bullet @@ -0,0 +1,21 @@ +#include +#include + +class Bullet +{ + public: + sf::ConvexShape convex; + + int statement=0; + + Bullet() + { + convex.setPointCount(5); + convex.setPoint(0, sf::Vector2f(5, 0)); + convex.setPoint(1, sf::Vector2f(0, 5)); + convex.setPoint(2, sf::Vector2f(0, 20)); + convex.setPoint(3, sf::Vector2f(10, 20)); + convex.setPoint(4, sf::Vector2f(10, 5)); + } + +}; From cb0845c58e86adbdb74f1fd6b70f08c7112c5c9d Mon Sep 17 00:00:00 2001 From: jinshayumi <791682161@QQ.COM> Date: Fri, 23 Jun 2017 15:02:16 +0800 Subject: [PATCH 28/39] canvas --- practices/cpp/level1/canvas | 81 +++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 practices/cpp/level1/canvas diff --git a/practices/cpp/level1/canvas b/practices/cpp/level1/canvas new file mode 100644 index 00000000..0dcbc04c --- /dev/null +++ b/practices/cpp/level1/canvas @@ -0,0 +1,81 @@ +#include +using namespace std; +#include "Shape.h" +#include "Canvas.h" + + +Canvas::Canvas() +{ + Shape* data[20]={0}; + num=0; +} +void Canvas::add(Shape* shape_0) +{ + data[num]=shape_0; + num++; +} +void Canvas::showall() +{ + for(int i=1;i<=num;i++) + { + data[i]->show();#ifndef CIRCLE_H +#define CIRCLE_H + +class Circle :public Shape +{ + public: + void add();#include +using namespace std; +#include "Shape.h" +#include "Circle.h" +#include "Rect.h" +#include "Canvas.h" + +/* run this program using the console pauser or add your own getch, system("pause") or input loop */ + +int main(int argc, char** argv) { + Canvas canvas; + Shape shape; + Circle circle; + Rect rect; + canvas.showall(); + rect.add(); + circle.add(); + #ifndef RECT_H +#define RECT_H + +class Rect :public Shape +{ + public: + void add(); + virtual void show(); + protected: + int a,b,c,d; +};#ifndef SHAPE_H +#define SHAPE_H + +class Shape +{ + public: + virtual void show(){}; + protected: + +}; + +#endif + + +#endif + + return 0; +} + + virtual void show(); + protected: + int x,y,r; +}; + +#endif + + } +} From 416439be8a5b8189ba0cfe2f0bbdf1d0de3cabc4 Mon Sep 17 00:00:00 2001 From: jinshayumi <791682161@QQ.COM> Date: Fri, 23 Jun 2017 15:04:07 +0800 Subject: [PATCH 29/39] circuit --- practices/cpp/level1/circuit | 96 ++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 practices/cpp/level1/circuit diff --git a/practices/cpp/level1/circuit b/practices/cpp/level1/circuit new file mode 100644 index 00000000..9d462bc5 --- /dev/null +++ b/practices/cpp/level1/circuit @@ -0,0 +1,96 @@ +#include +#include "circuit.h" +using namespace std; + +void PowerOn::Circuit() +{ + Allstate=1; +} + +void PowerOff::Circuit() +{ + Allstate=0; +} + +void ShowState() +{ + printf("锟斤拷状态为%d",Allstate); +} + +void On::Fan() +{#include +using namespace std; + +class Circuit +{ + public: + int Allstate; + void PowerOn(); + void PowerOff(); + void ShowState(); +}; + +class Item +{ + public: + int num; +}; + +class Fan:public Item +{ + public: + int state; + void On(); + void AddFan(); +}; + +class Lamp:public Item +{ + public: + int state; + void On(); + void AddLamp(); +}; + + state=1; +} + +void AddFan::Fan() +{ + num++; +} + +void On::Lamp() +{ + state=1; +} + +void AddLamp::Lamp() +{ + num++; +} + + +#include +#include "circuit.h" +using namespace std; + +/* run this program using the console pauser or add your own getch, system("pause") or input loop */ + +int main(int argc, char** argv) +{ + Circuit Onecircuit; + Item item[10]; + Fan Myfan; + Lamp Mylamp; + + Onecircuit.PowerOn(); + Myfan.AddFan(); + Mylamp.AddLamp(); + + Myfan.On(); + Mylamp.On(); + + Onecircuit.PowerOff(); + return 0; +} From 5d8eee0ed435fd4658e871d5a5b893c00861218b Mon Sep 17 00:00:00 2001 From: jinshayumi <791682161@QQ.COM> Date: Fri, 23 Jun 2017 15:04:51 +0800 Subject: [PATCH 30/39] point and circle --- practices/cpp/level1/point and circle | 64 +++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 practices/cpp/level1/point and circle diff --git a/practices/cpp/level1/point and circle b/practices/cpp/level1/point and circle new file mode 100644 index 00000000..22244736 --- /dev/null +++ b/practices/cpp/level1/point and circle @@ -0,0 +1,64 @@ +#include +#include "pac.h" +using namespace std; + +int main() +{ + Point Onepoint; + Onepoint.define(1,1,1); + + Onepoint.move(3,5); + Onepoint.show(); + + Onepoint.expand(20); + Onepoint.show(); +} + + +#include +#include "pac.h" +using namespace std; + +void Point::move(float dx,float dy) +{ + cout<<"x锟斤拷锟斤拷锟狡讹拷锟斤拷"; + cin>>dx; + cout<<"y锟斤拷锟斤拷锟狡讹拷锟斤拷"; + cin>>dy; + x=x+dx; + y=y+dy; +} + +void Point::expand(float multiple) +{ + cout<<"锟斤拷锟斤拷锟斤拷:"; + cin>>multiple; + r=r*multiple; +} + +void Point::show() +{ + cout<<"圆锟斤拷为锟斤拷"< +using namespace std; + +class Point +{ + public: + float x,y,r; + void define(float a,float b,float c); + void move(float dx,float dy); + void expand(float multiple); + void show(); +}; From b787db56b992fb3ddab1fe94204bfa39befa70f5 Mon Sep 17 00:00:00 2001 From: jinshayumi <791682161@QQ.COM> Date: Fri, 23 Jun 2017 15:05:36 +0800 Subject: [PATCH 31/39] queue --- practices/cpp/level1/queue | 92 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 practices/cpp/level1/queue diff --git a/practices/cpp/level1/queue b/practices/cpp/level1/queue new file mode 100644 index 00000000..56cd49d3 --- /dev/null +++ b/practices/cpp/level1/queue @@ -0,0 +1,92 @@ +#include +#include "queue.h" +using namespace std; +/* run this program using the console pauser or add your own getch, system("pause") or input loop */ + +int main(int argc, char** argv) +{ + Queue MyQueue; + MyQueue.append(2); + MyQueue.pop(); + MyQueue.show(); + +} + +#include +#include "queue.h" +using namespace std; + +bool Queue::IsFull() +{ + if(tail==100) + { + return 1; + } + else + { + return 0; + } +} + +bool Queue::IsEmpty() +{ + if(tail==0) + { + return 1; + } + else + { + return 0; + } +} + +void Queue::append(int add) +{ + if(!IsFull) + { + tail++; + num[tail] =add; + } + else + { + printf("full"); + } +} + +void Queue::pop() +{ + if(!Isempty) + { + num[tail] ='0'; + tail--; + return 1; + } + else + { + printf("empty"); + } +} + +void show() +{ + printf("锟斤拷锟斤拷为锟斤拷%d",tail); +} + + +#include +#include "queue.h" +using namespace std; + +#define SIZE 100 +Class Queue +{ + private: + int tail; + int num[100]; + bool IsFull(); + bool IsEmpty(); + public: + void append(int add); + void pop(); + void show(); +}; From 3aacdd125a8c6c87f10d6a820939eae0abede5d8 Mon Sep 17 00:00:00 2001 From: jinshayumi <791682161@QQ.COM> Date: Fri, 23 Jun 2017 15:06:42 +0800 Subject: [PATCH 32/39] Update fighter main --- practices/cpp/level1/fighter main | 840 ++++++++++++++++++++++++++++-- 1 file changed, 807 insertions(+), 33 deletions(-) diff --git a/practices/cpp/level1/fighter main b/practices/cpp/level1/fighter main index 838e58aa..bd3f1ba7 100644 --- a/practices/cpp/level1/fighter main +++ b/practices/cpp/level1/fighter main @@ -1,26 +1,46 @@ #include #include +#include #include "music.h" #include "plane.h" +#include "enemy.h" +#include "menu.h" +#include "enbullet.h" +#include +#include +#include +#include "small.h" +#include "big.h" +#include "bigbullet.h" +#include "gift.h" +#include "super.h" + + +std::string Int_to_String(int n) +{ + std::stringstream ss; + ss<move(-5,0); + thing->move(-4,0); } if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right)) { - thing->move(5,0); + thing->move(4,0); } if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up)) { - thing->move(0,-5); + thing->move(0,-4); } if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down)) { - thing->move(0,5); + thing->move(0,4); } } @@ -30,32 +50,115 @@ int main() { sf::RenderWindow window(sf::VideoMode(1000,800), "play plane"); + window.setFramerateLimit(60); + double const pi=3.1415926; - //闊充箰 + //锟斤拷锟斤拷 Music mymusic; mymusic.play(); - //鑳屾櫙 + //锟斤拷锟斤拷 sf::Texture a; sf::Sprite b; - a.loadFromFile("back.png"); + a.loadFromFile("bg2.png"); b.setTexture(a); - //椋炴満 + //锟缴伙拷 sf::Texture texture; sf::Sprite self; - texture.loadFromFile("plane.png"); + texture.loadFromFile("feiji1.png"); self.setTexture(texture); + int myblood=100; + int energy=0; - //瀛愬脊 + //锟接碉拷 Bullet mybullet[200]; - //鍒濆浣嶇疆 + //锟叫伙拷 + Enemy enemy[100]; + int ennum=0; + + //小BOSS + Smallen small[100]; + int smallnum=0; + + //锟斤拷BOSS + Bigen big; + + //锟叫伙拷锟接碉拷 + Enbullet enbullet[200]; + + //小BOSS锟接碉拷 + Enbullet smbullet1[200]; + Enbullet smbullet2[200]; + Enbullet smbullet3[200]; + + //锟斤拷BOSS锟接碉拷 + Bigbullet bigbullet[100][9]; + + //锟斤拷锟斤拷 + Gift gift; + + //锟缴伙拷锟斤拷锟斤拷 + Super super[25]; + + //锟斤拷始位锟斤拷 self.setOrigin(50,50); self.setPosition(500,750); + int key=1; + + //时锟斤拷 + sf::Clock clock1;//锟叫伙拷锟斤拷锟斤拷 + sf::Clock clock2;//锟接碉拷锟劫讹拷 + sf::Clock clock3;//锟叫伙拷锟劫讹拷 + sf::Clock clock4;//锟接碉拷频锟斤拷 + sf::Clock clock5;//锟叫撅拷锟接碉拷频锟斤拷 + sf::Clock clock6;//锟叫撅拷锟接碉拷锟劫讹拷 + sf::Clock clock7;//小BOSS锟劫讹拷 + sf::Clock clock8;//小BOSS锟接碉拷 + sf::Clock clock9;//小BOSS锟接碉拷锟劫讹拷 + sf::Clock clock10;//锟斤拷BOSS锟劫讹拷 + sf::Clock clock11;//锟斤拷BOSS锟接碉拷 + sf::Clock clock12;//锟斤拷BOSS锟接碉拷锟劫讹拷 + sf::Clock clock13;//锟斤拷锟狡飞伙拷锟狡讹拷 + sf::Clock clock14;//血锟斤拷锟斤拷锟斤拷频锟斤拷 + + + //BLOOD锟斤拷示 + sf::Font font; + font.loadFromFile("Arial.ttf"); + + sf::Text blood; + blood.setFont(font);//锟斤拷锟斤拷 + blood.setString("Blood"); + blood.setCharacterSize(18); + blood.setFillColor(sf::Color::Red); + blood.setStyle(sf::Text::Bold); + blood.setPosition(10,700); + + //血锟斤拷锟斤拷示 + sf::RectangleShape rectangle(sf::Vector2f(12, 5)); + + //锟斤拷锟斤拷锟斤拷锟斤拷示 + sf::RectangleShape energyshape(sf::Vector2f(12, 5)); + + //锟狡凤拷 + double score=0; + + + sf::Text showscore; + showscore.setFont(font);//锟斤拷锟斤拷 + + showscore.setCharacterSize(18); + showscore.setFillColor(sf::Color::Red); + showscore.setStyle(sf::Text::Bold); + showscore.setPosition(10,720); + + + while (window.isOpen()) { sf::Event event; @@ -65,63 +168,734 @@ int main() { window.close(); } - //鍔ㄩ鏈 - if(self.getPosition().x>42&&self.getPosition().x<958&&self.getPosition().y>52&&self.getPosition().y<800) + + //锟斤拷锟接碉拷 + if (sf::Keyboard::isKeyPressed(sf::Keyboard::Space)) { - move(&self); + sf::Time elapsed4 = clock4.getElapsedTime(); + if(elapsed4.asSeconds()>=0.2) + { + for(int i=0;i<200;i++) + { + if(mybullet[i].statement==0) + { + mybullet[i].convex.setPosition(self.getPosition()); + mybullet[i].convex.move(0,-60); + mybullet[i].convex.move(-13,0); + mybullet[i].statement=1; + break; + } + + } + clock4.restart(); + } + + }//锟斤拷锟接碉拷 + }// while event + //锟斤拷锟缴伙拷 + if(self.getPosition().x>42&&self.getPosition().x<958&&self.getPosition().y>52&&self.getPosition().y<800) + { + move(&self); + }//锟斤拷锟缴伙拷 + + + + //锟叫伙拷锟斤拷锟斤拷 + sf::Time elapsed1 = clock1.getElapsedTime(); + + if(elapsed1.asSeconds()>=1.2) + { + for(int i=0;i<100;i++) + { + if(enemy[i].statement==0) + { + enemy[i].convex.setPosition(100+rand()%600,0); + enemy[i].statement=1; + ennum++; + break; + } } + clock1.restart(); + } - //鎵撳瓙寮 - if (sf::Keyboard::isKeyPressed(sf::Keyboard::Space)) + + sf::Time elapsed3 = clock3.getElapsedTime(); + + if(elapsed3.asSeconds()>=0.02) + { + for(int i=0;i<100;i++) + { + if(enemy[i].statement==1) + { + enemy[i].convex.move(0,2); + } + if(enemy[i].convex.getPosition().y>800) + { + enemy[i].statement=0; + } + } + clock3.restart(); + } + //锟叫伙拷锟斤拷锟斤拷 + + //小BOSS锟斤拷锟斤拷锟斤拷锟斤拷 + + if(ennum%15==0&&ennum>0) + { + for(int i=0;i<100;i++) + { + if(small[i].statement==0) + { + small[i].convex.setPosition(100+rand()%600,0); + small[i].statement=1; + small[i].blood=6; + smallnum++; + break; + } + break; + } + } + + //锟狡讹拷小BOSS + sf::Time elapsed7 = clock7.getElapsedTime(); + + if(elapsed7.asSeconds()>=0.02) + { + for(int i=0;i<100;i++) + { + if(small[i].statement==1) + { + small[i].convex.move(0,0.5); + } + if(small[i].convex.getPosition().y>800) + { + small[i].statement=0; + } + } + clock7.restart(); + } + //小BOSS锟斤拷锟斤拷 + + //锟斤拷BOSS锟斤拷锟斤拷 + if(smallnum==6&&big.statement==0) + { + big.convex.setPosition(410,-180); + big.statement=1; + big.blood=50; + } + + //锟狡讹拷锟斤拷BOSS + sf::Time elapsed10 = clock10.getElapsedTime(); + + if(elapsed10.asSeconds()>=0.02) + { + if(big.statement==1) + { + big.convex.move(0,0.1); + } + clock10.restart(); + } + + + //锟缴伙拷锟接碉拷锟劫度达拷锟斤拷 + sf::Time elapsed2 = clock2.getElapsedTime(); + + if(elapsed2.asSeconds()>=0.02) + { + for(int i=0;i<200;i++) + { + if(mybullet[i].statement==1) + { + mybullet[i].convex.move(0,-8); + + } + + if(mybullet[i].convex.getPosition().y<-20) + { + mybullet[i].statement=0; + } + + } + clock2.restart(); + } + //锟缴伙拷锟接碉拷锟劫度达拷锟斤拷 + + //锟叫伙拷锟接碉拷锟斤拷锟斤拷 + + //锟斤拷锟斤拷锟叫撅拷锟接碉拷 + sf::Time elapsed5 = clock5.getElapsedTime(); + + if(elapsed5.asSeconds()>=1.5) + { + clock5.restart(); + if(rand()%2) { - for(int i=0;i<200;i++) + for(int i=0;i<100;i++) { - if(mybullet[i].statement==0) + if(enemy[i].statement==1) { - mybullet[i].convex.setPosition(self.getPosition()); - mybullet[i].convex.move(0,-50); - mybullet[i].convex.move(-13,0); - mybullet[i].statement=1; - break; + for(int m=0;m<200;m++) + { + if(smbullet1[m].statement==0) + { + smbullet1[m].shape.setPosition(enemy[i].convex.getPosition()); + smbullet1[m].shape.move(22,70); + smbullet1[m].statement=1; + break; + } + } + } } + } + + } + + //锟叫撅拷锟接碉拷锟劫讹拷 + sf::Time elapsed6 = clock6.getElapsedTime(); + + if(elapsed6.asSeconds()>=0.02) + { + for(int i=0;i<200;i++) + { + if(enbullet[i].statement==1) + { + enbullet[i].shape.move(0,3); + + } + if(enbullet[i].shape.getPosition().y>800) + { + enbullet[i].statement=0; + } } + clock6.restart(); + } + + //锟斤拷锟斤拷小BOSS锟接碉拷 + sf::Time elapsed8 = clock8.getElapsedTime(); + + if(elapsed8.asSeconds()>=1.5) + { + clock8.restart(); + if(rand()%3) + { + for(int i=0;i<100;i++) + { + if(small[i].statement==1) + { + for(int m=0;m<200;m++) + { + if(smbullet1[m].statement==0) + { + smbullet1[m].shape.setPosition(small[i].convex.getPosition()); + smbullet1[m].shape.move(50,120); + smbullet1[m].statement=1; + break; + } + } + for(int m=0;m<200;m++) + { + if(smbullet2[m].statement==0) + { + smbullet2[m].shape.setPosition(small[i].convex.getPosition()); + smbullet2[m].shape.move(50,120); + smbullet2[m].statement=1; + break; + } + } + for(int m=0;m<200;m++) + { + if(smbullet3[m].statement==0) + { + smbullet3[m].shape.setPosition(small[i].convex.getPosition()); + smbullet3[m].shape.move(50,120); + smbullet3[m].statement=1; + break; + } + } + + } + } + } } + //锟斤拷锟斤拷小BOSS锟接碉拷 + //锟斤拷锟斤拷锟斤拷BOSS锟接碉拷 + sf::Time elapsed11 = clock11.getElapsedTime(); + if(elapsed11.asSeconds()>=3&&big.statement==1) + { + for(int i=0;i<100;i++) + { + if(bigbullet[i][0].statement==0) + { + for(int m=0;m<9;m++) + { + bigbullet[i][m].statement=1; + bigbullet[i][m].shape.setPosition(big.convex.getPosition()); + bigbullet[i][m].shape.move(90,90); + bigbullet[i][m].shape.move(-90*cos(((30+15*m)*pi)/180),90*sin(((30+15*m)*pi)/180)); + } + break; + } + } + clock11.restart(); + } + //锟斤拷锟斤拷锟斤拷BOSS锟接碉拷 + //小BOSS锟接碉拷锟劫讹拷 + sf::Time elapsed9 = clock9.getElapsedTime(); + if(elapsed9.asSeconds()>=0.03) + { + for(int i=0;i<200;i++) + { + if(smbullet1[i].statement==1) + { + smbullet1[i].shape.move(0,4); + + } + if(smbullet1[i].shape.getPosition().y>800) + { + smbullet1[i].statement=0; + } + + } + + for(int i=0;i<200;i++) + { + if(smbullet2[i].statement==1) + { + smbullet2[i].shape.move(-3,4); + + } + if(smbullet2[i].shape.getPosition().y>800) + { + smbullet2[i].statement=0; + } + + } + + for(int i=0;i<200;i++) + { + if(smbullet3[i].statement==1) + { + smbullet3[i].shape.move(3,4); + + } + if(smbullet3[i].shape.getPosition().y>800) + { + smbullet3[i].statement=0; + } + + } + clock9.restart(); + } + + //锟斤拷BOSS锟接碉拷锟劫讹拷 + sf::Time elapsed12 = clock12.getElapsedTime(); + + if(elapsed12.asSeconds()>=0.03) + { + for(int i=0;i<100;i++) + { + if(bigbullet[i][0].statement==1) + { + for(int m=0;m<9;m++) + { + bigbullet[i][m].shape.move(-3*cos(((30+15*m)*pi)/180),3*sin(((30+15*m)*pi)/180)); + } + } + if(bigbullet[i][0].shape.getPosition().y>800) + { + for(int m=0;m<9;m++) + { + bigbullet[i][m].statement=0; + } + } + } + clock12.restart(); + } + + + + //锟接碉拷锟斤拷谢锟斤拷锟阶 + for(int i=0;i<100;i++) + { + if(enemy[i].statement==1) + { + for(int m=0;m<200;m++) + { + if(mybullet[m].statement==1) + { + if(mybullet[m].convex.getGlobalBounds().intersects(enemy[i].convex.getGlobalBounds())) + { + mybullet[m].statement=0; + enemy[i].statement=0; + score=score+30; + energy++; + } + } + } + } + } + + //锟接碉拷锟斤拷小BOSS锟斤拷撞 + for(int i=0;i<100;i++) + { + if(small[i].statement==1) + { + for(int m=0;m<200;m++) + { + if(mybullet[m].statement==1) + { + if(mybullet[m].convex.getGlobalBounds().intersects(small[i].convex.getGlobalBounds())) + { + mybullet[m].statement=0; + small[i].blood--; + energy++; + } + } + if(small[i].blood<1) + { + small[i].statement=0; + score=score+1; + } + } + } + } + + //锟接碉拷锟斤拷锟紹OSS锟斤拷撞 + for(int m=0;m<200;m++) + { + if(mybullet[m].statement==1) + { + if(mybullet[m].convex.getGlobalBounds().intersects(big.convex.getGlobalBounds())) + { + mybullet[m].statement=0; + big.blood--; + } + } + if(big.blood<1) + { + big.statement=0; + key=0; + } + } + + + //锟叫碉拷锟斤拷锟斤拷 + for(int i=0;i<=200;i++) + { + if(enbullet[i].statement==1) + { + if(self.getGlobalBounds().intersects(enbullet[i].shape.getGlobalBounds())) + { + myblood=myblood-5; + enbullet[i].statement=0; + } + } + } + + //锟斤拷小BOSS锟接碉拷 + for(int i=0;i<=200;i++) + { + if(smbullet1[i].statement==1) + { + if(self.getGlobalBounds().intersects(smbullet1[i].shape.getGlobalBounds())) + { + myblood=myblood-5; + smbullet1[i].statement=0; + } + } + } + + for(int i=0;i<=200;i++) + { + if(smbullet2[i].statement==1) + { + if(self.getGlobalBounds().intersects(smbullet2[i].shape.getGlobalBounds())) + { + myblood=myblood-5; + smbullet2[i].statement=0; + } + } + } + + for(int i=0;i<=200;i++) + { + if(smbullet3[i].statement==1) + { + if(self.getGlobalBounds().intersects(smbullet3[i].shape.getGlobalBounds())) + { + myblood=myblood-5; + smbullet3[i].statement=0; + } + } + } + //锟斤拷小BOSS锟接碉拷 + + + //锟叫达拷BOSS锟接碉拷 + for(int i=0;i<100;i++) + { + for(int m=0;m<9;m++) + { + if(bigbullet[i][m].statement==1) + { + if(self.getGlobalBounds().intersects(bigbullet[i][m].shape.getGlobalBounds())) + { + myblood=myblood-5; + bigbullet[i][m].statement=0; + } + } + + } + } + + + + //锟缴伙拷锟斤拷谢锟斤拷锟斤拷锟阶 + for(int i=0;i<100;i++) + { + if(enemy[i].statement==1) + { + if(self.getGlobalBounds().intersects(enemy[i].convex.getGlobalBounds())) + { + myblood=myblood-8; + enemy[i].statement=0; + } + } + } + + //锟缴伙拷锟斤拷小BOSS锟斤拷锟斤拷撞 + for(int i=0;i<100;i++) + { + if(small[i].statement==1) + { + if(self.getGlobalBounds().intersects(small[i].convex.getGlobalBounds())) + { + myblood=myblood-15; + small[i].statement=0; + } + } + } + + //锟斤拷锟斤拷血锟斤拷 + sf::Time elapsed14 = clock14.getElapsedTime(); + + if(elapsed14.asSeconds()>=15) + { + gift.statement=1; + gift.convex.setPosition(100+rand()%600,0); + + clock14.restart(); + } + + //血锟斤拷锟狡讹拷 + if(gift.statement==1) + { + gift.convex.move(0,3); + } + if(gift.convex.getPosition().y>800) + { + gift.statement=0; + } + + //锟斤拷血锟斤拷 + if(gift.statement==1) + { + if(self.getGlobalBounds().intersects(gift.convex.getGlobalBounds())) + { + myblood=myblood+20; + gift.statement=0; + } + } + + //锟缴伙拷锟斤拷锟叫达拷锟斤拷 + if(energy>10) + { + for(int i=0;i<25;i++) + { + super[i].statement=1; + super[i].shape.setPosition(100+32*i,800); + } + energy=0; + } + + + for(int i=0;i<25;i++) + { + if(super[i].statement==1) + { + super[i].shape.move(0,-3); + } + if(super[i].shape.getPosition().y<0) + { + super[i].statement=0; + } + } + + //锟缴伙拷锟斤拷锟斤拷撞锟斤拷锟叫伙拷 + for(int i=0;i<25;i++) + { + for(int m=0;m<100;m++) + { + if(super[i].shape.getGlobalBounds().intersects(enemy[m].convex.getGlobalBounds())) + { + super[i].statement=0; + enemy[m].statement=0; + + } + } + } + + //锟缴伙拷锟斤拷锟斤拷撞锟斤拷小boss + for(int i=0;i<25;i++) + { + for(int m=0;m<100;m++) + { + if(super[i].shape.getGlobalBounds().intersects(small[m].convex.getGlobalBounds())) + { + super[i].statement=0; + small[m].statement=0; + + } + } + } + + + + + + + //锟斤拷示锟斤拷锟斤拷 + showscore.setString("Score:"+Int_to_String(score)); + + //锟斤拷血锟斤拷 + rectangle.setSize(sf::Vector2f(1.5*myblood, 10)); + rectangle.setPosition(62,708); + rectangle.setFillColor(sf::Color::Red); + + //锟斤拷锟斤拷锟斤拷锟斤拷 + energyshape.setSize(sf::Vector2f(1.5*energy, 10)); + energyshape.setPosition(10,745); + energyshape.setFillColor(sf::Color::Yellow); + + + window.clear(); + window.draw(b); + window.draw(blood); + window.draw(showscore); + window.draw(rectangle); + window.draw(self); + window.draw(energyshape); + + //锟斤拷锟接碉拷 for(int i=0;i<200;i++) { if(mybullet[i].statement==1) { - mybullet[i].convex.move(0,-2); + window.draw(mybullet[i].convex); + } + } + + //锟斤拷锟叫撅拷锟接碉拷 + for(int i=0;i<200;i++) + { + if(enbullet[i].statement==1) + { + window.draw(enbullet[i].shape); } - if(mybullet[i].convex.getPosition().y<-20) + } + + //锟斤拷锟叫伙拷 + for(int i=0;i<100;i++) + { + if(enemy[i].statement==1) { - mybullet[i].statement=0; + window.draw(enemy[i].convex); } + } + //锟斤拷小BOSS + for(int i=0;i<100;i++) + { + if(small[i].statement==1) + { + window.draw(small[i].convex); + } } - window.clear(); - window.draw(b); - window.draw(self); + //锟斤拷锟斤拷BOSS + if(big.statement==1) + { + window.draw(big.convex); + } - for(int i=0;i<200;i++) + //锟斤拷小BOSS锟接碉拷 + for(int i=0;i<200;i++) + { + if(smbullet1[i].statement==1) { - if(mybullet[i].statement==1) + window.draw(smbullet1[i].shape); + } + } + + for(int i=0;i<200;i++) + { + if(smbullet2[i].statement==1) + { + window.draw(smbullet2[i].shape); + } + } + + for(int i=0;i<200;i++) + { + if(smbullet3[i].statement==1) + { + window.draw(smbullet3[i].shape); + } + } + + //锟斤拷锟斤拷BOSS锟接碉拷 + for(int i=0;i<100;i++) + { + for(int m=0;m<9;m++) + { + if(bigbullet[i][m].statement==1) { - window.draw(mybullet[i].convex); + window.draw(bigbullet[i][m].shape); } + } + + } + //锟斤拷血锟斤拷 + if(gift.statement==1) + { + window.draw(gift.convex); + } + + //锟斤拷锟缴伙拷锟斤拷锟斤拷 + for(int i=0;i<25;i++) + { + if(super[i].statement==1) + { + window.draw(super[i].shape); } - window.display(); + } + + + window.display(); } + + return 0; } + From b828a322a555a8fd5e24cc37292068f65b6f5ef8 Mon Sep 17 00:00:00 2001 From: jinshayumi <791682161@QQ.COM> Date: Fri, 23 Jun 2017 15:08:33 +0800 Subject: [PATCH 33/39] bigboss --- practices/cpp/level1/big boss.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 practices/cpp/level1/big boss.h diff --git a/practices/cpp/level1/big boss.h b/practices/cpp/level1/big boss.h new file mode 100644 index 00000000..c48c9989 --- /dev/null +++ b/practices/cpp/level1/big boss.h @@ -0,0 +1,19 @@ +#include +#include + +class Bigen +{ + public: + sf::Sprite convex; + sf::Texture pic; + int statement=0; + int blood; + sf::FloatRect Bigenbounding; + + Bigen() + { + + pic.loadFromFile("big.png"); + convex.setTexture(pic); + } +}; From 4528cdd5a190701400bfd48146147b91c2ccfcf4 Mon Sep 17 00:00:00 2001 From: jinshayumi <791682161@QQ.COM> Date: Fri, 23 Jun 2017 15:08:56 +0800 Subject: [PATCH 34/39] Create bigbullet --- practices/cpp/level1/bigbullet | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 practices/cpp/level1/bigbullet diff --git a/practices/cpp/level1/bigbullet b/practices/cpp/level1/bigbullet new file mode 100644 index 00000000..7c2a8822 --- /dev/null +++ b/practices/cpp/level1/bigbullet @@ -0,0 +1,18 @@ +#include +#include + + +class Bigbullet +{ + public: + sf::Sprite shape; + sf::Texture pic; + int statement=0; + sf::FloatRect Bigbulletbounding; + Bigbullet() + { + pic.loadFromFile("star.png"); + shape.setTexture(pic); + } +}; + From 01cb96f749ea3ce87afe8c02b31af1dab9673591 Mon Sep 17 00:00:00 2001 From: jinshayumi <791682161@QQ.COM> Date: Fri, 23 Jun 2017 15:09:14 +0800 Subject: [PATCH 35/39] Create enemy --- practices/cpp/level1/enemy | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 practices/cpp/level1/enemy diff --git a/practices/cpp/level1/enemy b/practices/cpp/level1/enemy new file mode 100644 index 00000000..306e36f6 --- /dev/null +++ b/practices/cpp/level1/enemy @@ -0,0 +1,16 @@ +#include +#include + +class Enemy +{ + public: + sf::Texture pic; + sf::Sprite convex; + int statement=0; + + Enemy() + { + pic.loadFromFile("enemy.png"); + convex.setTexture(pic); + } +}; From e972ccadafb60a8e27424c2f14504774c989aa99 Mon Sep 17 00:00:00 2001 From: jinshayumi <791682161@QQ.COM> Date: Fri, 23 Jun 2017 15:09:37 +0800 Subject: [PATCH 36/39] Create gift --- practices/cpp/level1/gift | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 practices/cpp/level1/gift diff --git a/practices/cpp/level1/gift b/practices/cpp/level1/gift new file mode 100644 index 00000000..37dc3fc1 --- /dev/null +++ b/practices/cpp/level1/gift @@ -0,0 +1,15 @@ +#include +#include + +class Gift +{ + public: + sf::Sprite convex; + sf::Texture pic; + int statement=0; + Gift() + { + pic.loadFromFile("gift.png"); + convex.setTexture(pic); + } +}; From b47f33839b3f6cdcff704fb4bcd84794de8647ae Mon Sep 17 00:00:00 2001 From: jinshayumi <791682161@QQ.COM> Date: Fri, 23 Jun 2017 15:10:59 +0800 Subject: [PATCH 37/39] Create smallboss --- practices/cpp/level1/smallboss | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 practices/cpp/level1/smallboss diff --git a/practices/cpp/level1/smallboss b/practices/cpp/level1/smallboss new file mode 100644 index 00000000..5f27b258 --- /dev/null +++ b/practices/cpp/level1/smallboss @@ -0,0 +1,20 @@ +#include +#include + + +class Smallen +{ + public: + sf::Sprite convex; + sf::Texture pic; + int statement=0; + int blood; + sf::FloatRect Smallenbounding; + + Smallen() + { + + pic.loadFromFile("small3.png"); + convex.setTexture(pic); + } +}; From b7856680a9a10da536dfe64887b075ebaa0e015e Mon Sep 17 00:00:00 2001 From: jinshayumi <791682161@QQ.COM> Date: Fri, 23 Jun 2017 15:11:23 +0800 Subject: [PATCH 38/39] Create smallbullet --- practices/cpp/level1/smallbullet | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 practices/cpp/level1/smallbullet diff --git a/practices/cpp/level1/smallbullet b/practices/cpp/level1/smallbullet new file mode 100644 index 00000000..a273484b --- /dev/null +++ b/practices/cpp/level1/smallbullet @@ -0,0 +1,21 @@ +#include +#include + +class Smbullet +{ + public: + sf::ConvexShape shape; + int statement=0; + sf::FloatRect Smbulletbounding; + Enbullet() + { + shape.setPointCount(3); + shape.setPoint(0, sf::Vector2f(10, 10)); + shape.setPoint(1, sf::Vector2f(20, 0)); + shape.setPoint(2, sf::Vector2f(0, 0)); + + shape.setFillColor(sf::Color(150, 50, 250)); + shape.setOutlineThickness(1); + shape.setOutlineColor(sf::Color(250, 150, 100)); + } +}; From dda98abd1f1b96470fd8f18228bff9ab3a623b2e Mon Sep 17 00:00:00 2001 From: jinshayumi <791682161@QQ.COM> Date: Fri, 23 Jun 2017 15:11:36 +0800 Subject: [PATCH 39/39] Create super skill --- practices/cpp/level1/super skill | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 practices/cpp/level1/super skill diff --git a/practices/cpp/level1/super skill b/practices/cpp/level1/super skill new file mode 100644 index 00000000..259f5969 --- /dev/null +++ b/practices/cpp/level1/super skill @@ -0,0 +1,16 @@ +#include +#include + + +class Super +{ + public: + sf::Sprite shape; + sf::Texture pic; + int statement=0; + Super() + { + pic.loadFromFile("super.png"); + shape.setTexture(pic); + } +};