-
个人简介
暗区突围,启动!
想加我的暗区微区的话,搜索二老孟//
我有900万了
https://fun.360.cn/playgame?ad_source=iaa&djsource=Oc0Ca1&gameId=1027&srcid=Microsoft&msstart_sdk_init=eyJwYXJlbnRPcmlnaW4iOiJodHRwczovL3d3dy5tc24uY24iLCJjbGllbnRJZCI6IjI1MDMyNDhDRjA5NzZBRTAyQTM5MzFCNUYxM0I2QjBFIiwibG9jYWxlIjoiemgtY24iLCJlbnRyeVBvaW50SWQiOiJ3aW5kX3Nwb3RfY2czMDIifQ
最喜欢的网址: https://poki.com/zh/g/combat-reloaded 惊喜==https://www.minecraft.net/zh-hans 另一个学习网址:https://oiclass.com/ https://game.fm/city-sniper-826/?scoresType=game#google_vignette
小游戏:
/************************贪吃蛇***********************/ /**********************2012-11-20*********************/ #include <iostream> #include <cstdio> #include <cstdlib> #include <ctime> #include <conio.h> #include <cmath> #include <windows.h> using namespace std; /*** 光标定位 ***/ HANDLE hout=GetStdHandle(STD_OUTPUT_HANDLE); COORD coord; void locate(int x,int y) { coord.X=y; coord.Y=x; SetConsoleCursorPosition(hout,coord); }; /*** 隐藏光标 ***/ void hide() { CONSOLE_CURSOR_INFO cursor_info={1,0}; SetConsoleCursorInfo(hout, &cursor_info); } /*** 生成随机数 ***/ double random(double start, double end) { return start+(end-start)*rand()/(RAND_MAX + 1.0); } /*** 定义地图的长宽,蛇的坐标,长度,方向,食物的位置 ***/ int m,n; struct node { int x,y; }snake[1000]; int snake_length,dir; node food; int direct[4][2]={{-1,0},{1,0},{0,-1},{0,1}}; /*** 输出墙 ***/ void print_wall() { cout << " "; for (int i=1;i<=n;i++) cout << "-"; cout << endl; for (int j=0;j<=m-1;j++) { cout << "|"; for (int i=1;i<=n;i++) cout << " "; cout << "|" << endl; } cout << " "; for (int i=1;i<=n;i++) cout << "-"; } /*** 首次输出蛇,其中snake[0]代表头 ***/ void print_snake() { locate(snake[0].x,snake[0].y); cout << "@"; for (int i=1;i<=snake_length-1;i++) { locate(snake[i].x,snake[i].y); cout << "*"; } } /*** 判断是否撞墙或者自撞 ***/ bool is_correct() { if (snake[0].x==0 || snake[0].y==0 || snake[0].x==m+1 || snake[0].y==n+1) return false; for (int i=1;i<=snake_length-1;i++) { if (snake[0].x==snake[i].x && snake[0].y==snake[i].y) return false; } return true; } /*** 随机生成并输出食物位置 ***/ bool print_food() { srand((unsigned)time(0)); bool e; while (1) { e=true; int i=(int) random(0,m)+1,j=(int) random(0,n)+1; food.x=i;food.y=j; for (int k=0;k<=snake_length-1;k++) { if (snake[k].x==food.x && snake[k].y==food.y) { e=false;break; } } if (e) break; } locate(food.x,food.y); cout << "$"; return true; } /*** 蛇的前进 ***/ bool go_ahead() { node temp; bool e=false; temp=snake[snake_length-1]; for (int i=snake_length-1;i>=1;i--) snake[i]=snake[i-1]; snake[0].x+=direct[dir][0]; snake[0].y+=direct[dir][1]; locate(snake[1].x,snake[1].y); cout << "*"; /*** 吃到了食物 ***/ if (snake[0].x==food.x && snake[0].y==food.y) { snake_length++; e=true; snake[snake_length-1]=temp; } /*** 输出此时蛇状态 ***/ if (!e) { locate(temp.x,temp.y); cout << " "; } else print_food(); locate(snake[0].x,snake[0].y); cout << "@"; /*** 如果自撞 ***/ if (!is_correct()) { system("cls"); cout << "You lose!" << endl << "Length: " << snake_length << endl; return false; } return true; } /*** 主函数 ***/ int main() { cout << "--------------------贪吃蛇---------------------" << endl; cout << "请注意窗口大小,以免发生错位.建议将窗口调为最大." << endl; cout << "先选择难度.请在1-10中输入1个数,1最简单,10则最难" << endl; cout << "然后进入游戏画面,以方向键控制方向.祝你游戏愉快!" << endl; cout << "-----------------------------------------------" << endl; m=25; n=40; if (m<10 || n<10 || m>25 || n>40) { cout << "ERROR" << endl; system("pause"); return 0; } int hard; cin >> hard; if (hard<=0 || hard>100) { cout << "ERROR" << endl; system("pause"); return 0; } /*** 数据全部初始化,包括蛇长,位置,方向 ***/ snake_length=5; clock_t a,b; char ch; double hard_len; for (int i=0;i<=4;i++) { snake[i].x=1; snake[i].y=5-i; } dir=3; /*** 输出初始地图,蛇与食物 ***/ system("cls"); hide(); print_wall(); print_food(); print_snake(); locate(m+2,0); cout << "Now length: "; /*** 开始游戏 ***/ while (1) { /*** 难度随长度增加而提高 ***/ hard_len=(double)snake_length/(double) (m*n); /*** 调节时间,单位是ms ***/ a=clock(); while (1) { b=clock(); if (b-a>=(int)(400-30*hard)*(1-sqrt(hard_len))) break; } /*** 接受键盘输入的上下左右,并以此改变方向 ***/ if (kbhit()) { ch=getch(); if (ch==-32) { ch=getch(); switch(ch) { case 72: if (dir==2 || dir==3) dir=0; break; case 80: if (dir==2 || dir==3) dir=1; break; case 75: if (dir==0 || dir==1) dir=2; break; case 77: if (dir==0 || dir==1) dir=3; break; } } } /*** 前进 ***/ if (!go_ahead()) break; /*** 在最后输出此时长度 ***/ locate(m+2,12); cout << snake_length; } system("pause"); return 0; }
俄罗斯方块
#include<iostream> #include<string> #include<cstdlib> #include<windows.h> #include<ctime> #include<conio.h> #include<cstdio> using namespace std; class Tetris { private: int rank; //游戏难度等级 int score; // 得分 int id; //图形ID int point[2]; //两基点 int top; //最高点高度 public: Tetris(); void Welocme(); //首界面 void DrawMap(); //游戏界面 void SetColor(int); //控制颜色 void Draw(int, int, int); //画图形 void Run(); //运行游戏 void ReDraw(int, int, int); //清除图形 bool Judge(int, int, int); void Turn(int); //旋转 void Updata(); // 更新界面 void Pause(); //游戏暂停 void Input_score(); }; const int sharp[15][8] = //组成图形的各个点的各个坐标,先纵后横 { {0,0,1,0,2,0,3,0},{0,0,0,1,0,2,0,3}, {0,0,1,0,0,1,1,1}, {0,0,1,0,1,1,1,2},{0,1,1,1,2,0,2,1},{0,0,0,1,0,2,1,2},{0,0,0,1,1,0,2,0}, {1,0,1,1,1,2,0,2},{0,0,0,1,1,1,2,1},{0,0,0,1,0,2,1,0},{0,0,1,0,2,0,2,1}, {0,0,0,1,1,1,1,2},{0,1,1,0,1,1,2,0}, {0,1,0,2,1,0,1,1},{0,0,1,0,1,1,2,1} }; const int high[15] = { 4,1,2,2,3,2,3,2,3,2,3,2,3,2,3 }; int map[28][16]; #define a1 0 //条形 #define a2 1 #define b 2 // 方块 #define c1 3 //L形 #define c2 4 #define c3 5 #define c4 6 #define d1 7 //T形 #define d2 8 #define d3 9 #define d4 10 #define e1 11 //闪电1形 #define e2 12 #define f1 13 //闪电2形 #define f2 14 Tetris::Tetris() //构造函数, 初始化各个值 { point[0] = 0; point[1] = 5; score = 0; top = 25; } void Tetris::Turn(int num) //旋转函数 { switch (num) { case a1: id = a2; break; //条形互换 case a2: id = a1; break; case b: id = b; break; //方块无法旋转 case c1: id = c2; break; //各种L形互换 case c2: id = c3; break; case c3: id = c4; break; case c4: id = c1; break; case d1: id = d2; break; //各种T形互换 case d2: id = d3; break; case d3: id = d4; break; case d4: id = d1; break; case e1: id = e2; break; //两种闪电形互换 case e2: id = e1; break; case f1: id = f2; break; case f2: id = f1; break; } } void SetPos(int i, int j) //控制光标位置, 列, 行 { COORD pos = { i,j }; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos); } void Tetris::Pause() // 暂停函数 { SetPos(32, 10); cout << "游戏暂停!" << endl; SetPos(30, 11); cout << "你的分数为 " << score; char temp; while (1) { while (1) { if (_kbhit()) { temp = _getch(); break; } } if (temp == 32) break; } SetPos(32, 10); // 清除暂停时显示的信息 cout << " "; SetPos(30, 11); cout << " "; } void Tetris::Updata() //更新函数 { int i, flag; int nx, ny; for (i = 0; i < 4; i++) { nx = point[0] + sharp[id][i * 2]; ny = point[1] + sharp[id][i * 2 + 1]; SetPos((ny + 1) * 2, nx + 1); SetColor(0); cout << "■"; map[nx][ny] = 1; //界面各个点是否为空的更新 } if (point[0] < top) top = point[0]; //最高点的更新 for (i = point[0]; i < point[0] + high[id]; i++) //消除行 { flag = 1; for (int j = 0; j < 13; j++) //判定某一行是否满, 用flag来标记 if (map[i][j] == 0) flag = 0; if (flag == 1) { for (int k = i; k >= top; k--) { for (int p = 0; p < 13; p++) { map[k][p] = map[k - 1][p]; SetPos((p + 1) * 2, k + 1); if (map[k][p] == 1) cout << "■"; else cout << " "; } } score += 10; Input_score(); } } } void Tetris::Input_score() { SetColor(3); SetPos(30, 19); cout << "得分: " << score; } void Tetris::Welocme() //欢迎界面 { SetColor(1); char x; while (1) { system("cls"); cout << "■■■■■■■■■■■■■■■■■■■■■" << endl; cout << " 俄罗斯方块 " << endl; cout << "■■■■■■■■■■■■■■■■■■■■■" << endl; cout << " 操作方式:" << endl; cout << " ↑ - 旋转" << endl; cout << " ↓ - 加速下移" << endl; cout << " ← - 左移" << endl; cout << " → - 右移" << endl; cout << " 空格 - 暂停" << endl; cout << "■■■■■■■■■■■■■■■■■■■■■" << endl; cout << "■ 按1—3选择难度■" << endl; SetPos(20, 10); x = getchar(); if (x <= '9' && x >= '0') { rank = x - '0'; break; } } } void Tetris::SetColor(int color_num) //设置颜色 { int n; switch (color_num) { case 0: n = 0x08; break; case 1: n = 0x0C; break; case 2: n = 0x0D; break; case 3: n = 0x0E; break; case 4: n = 0x0A; break; } SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), n); } void Tetris::DrawMap() //画游戏时界面 { int i; SetColor(0); for (i = 0; i < 24; i++) //宽24格 { SetPos(i * 2, 0); cout << "■"; SetPos(i * 2, 26); cout << "■"; } for (i = 0; i < 26; i++) //高26格 { SetPos(0, i); cout << "■"; SetPos(28, i); cout << "■"; SetPos(46, i); cout << "■"; } for (i = 14; i < 24; i++) { SetPos(i * 2, 16); cout << "■"; } SetColor(3); Input_score(); SetPos(30, 21); cout << "难度等级: " << rank; SetPos(32, 2); cout << "下一图形"; } void Tetris::Draw(int x, int y, int num) //画图形 { int nx, ny; for (int i = 0; i < 4; i++) { nx = x + sharp[num][2 * i]; ny = y + sharp[num][2 * i + 1]; SetPos((ny + 1) * 2, nx + 1); SetColor(i + 1); cout << "■"; } } void Tetris::ReDraw(int x, int y, int num) //为更新图形的位置清除图形 { int nx, ny; for (int i = 0; i < 4; i++) { nx = x + sharp[num][2 * i]; ny = y + sharp[num][2 * i + 1]; SetPos((ny + 1) * 2, nx + 1); cout << " "; } } bool Tetris::Judge(int x, int y, int num) //判定在x, y 所指位置是否可画编号为 { //num 的图形, 若不可画则反回true int nx, ny; for (int i = 0; i < 4; i++) { nx = x + sharp[num][2 * i]; ny = y + sharp[num][2 * i + 1]; if (!(nx < 25 && nx >= 0 && ny < 13 && ny >= 0 && !map[nx][ny])) return true; } return false; } void Tetris::Run() //运行游戏 { int next_id; srand((int)time(0)); id = rand() % 15; next_id = rand() % 15; Draw(point[0], point[1], id); Draw(5, 16, next_id); int count; if (rank == 1) count = 150; else if (rank == 2) count = 100; else if (rank==3) count = 50; else count = 5; int i = 0; //不同等级对应不同count while (1) { if (!(i < count)) //i 与 count 用于控制时间 { i = 0; if (Judge(point[0] + 1, point[1], id)) //在某一位置不能下落的话 { Updata(); id = next_id; ReDraw(5, 16, next_id); next_id = rand() % 15; point[0] = 0; point[1] = 5; Draw(point[0], point[1], id); Draw(5, 16, next_id); if (Judge(point[0], point[1], id)) { system("cls"); SetPos(20, 10); cout << "游戏结束!" << endl; SetPos(20, 11); cout << "你的分数为 " << score << endl; system("pause"); exit(1); } } else //继续下落 { ReDraw(point[0], point[1], id); point[0]++; Draw(point[0], point[1], id); } } if (_kbhit()) //键盘输入值时 { int key, key2; key = _getch(); if (key == 224) { key2 = _getch(); if (key2 == 72) //按向上方向键时 { int temp = id; Turn(id); if (Judge(point[0], point[1], id)) id = temp; ReDraw(point[0], point[1], temp); Draw(point[0], point[1], id); } if (key2 == 80) //按向下方向键时 { if (!Judge(point[0] + 2, point[1], id)) { ReDraw(point[0], point[1], id); point[0] += 2; Draw(point[0], point[1], id); } } else if (key2 == 75) //按向左方向键时 { if (!Judge(point[0], point[1] - 1, id)) { ReDraw(point[0], point[1], id); point[1]--; Draw(point[0], point[1], id); } } else if (key2 == 77) //按向右方向键时 { if (!Judge(point[0], point[1] + 1, id)) { ReDraw(point[0], point[1], id); point[1]++; Draw(point[0], point[1], id); } } } else if (key == 32) // 按下空格暂停 Pause(); } Sleep(1); //等待1毫秒 i++; //控制下落间隔 } } int main() { Tetris game; game.Welocme(); system("cls"); //清除欢迎界面 game.DrawMap(); game.Run(); }
#include<bits/stdc++.h> #include<windows.h> using namespace std; int b[5][100]; int d[5][100]; void print(string a,string c){ for(int i=0;i<a.size();i++){ cout<<a[i]; Sleep(1); } cout<<c; } void printg(int ty){ cout<<"|"; for(int i=1;i<=20;i++){ if(b[ty][i]==1) print("?",""); else if(b[ty][i]==2) print("@",""); else if(b[ty][i]==3) print(">",""); else print(" ",""); } cout<<"|"<<endl; } int main(){ print(" ----植物大战僵尸---- ","\n"); print(">是双向射手","\n"); print("@是向日葵","\n"); print("?是僵尸","\n"); Sleep(400); system("cls"); print("开始游戏","\n"); memset(b,0,sizeof(b)); while(true){ system("cls"); print(" ----植物大战僵尸---- ","\n"); printg(1); printg(2); printg(3); printg(4); printg(5); print(" -------------------- ","\n"); int x,y,z; cin>>x>>y>>z; b[x][y]=z; if(b[x][y]==1) d[x][y]=100; for(int i=1;i<=5;i++){ for(int j=1;j<=20;j++){ if(b[i][j]==1){ b[i][j]=0; b[i][j-1]=1; d[i][j-1]=d[i][j]; d[i][j]=0; } } } for(int i=1;i<=5;i++){ for(int j=1;j<=100;j++){ if(b[i][j]==3){ for(int k=1;k<=100;k++){ if(b[i][k]==1){ d[i][k]-=35; if(d[i][k]<=0) b[i][k]=0; break; } } } } } for(int i=1;i<=5;i++){ b[i][20]=1; } } return 0; }
-
通过的题目
- P1
- P2
- P3
- P5
- P6
- P7
- P8
- P10
- P11
- P12
- P14
- P15
- P16
- P17
- P18
- P19
- P20
- P21
- P22
- P23
- P24
- P26
- P28
- P32
- P33
- P34
- P35
- P42
- P48
- P49
- P55
- P59
- P64
- P66
- P70
- P80
- P81
- P90
- P91
- P95
- P97
- P100
- P103
- P106
- P107
- P108
- P112
- P113
- P114
- P115
- P116
- P117
- P118
- P119
- P120
- P121
- P124
- P130
- P135
- P146
- P147
- P152
- P158
- P159
- P164
- P173
- P176
- P177
- P184
- P188
- P190
- P197
- P205
- P206
- P208
- P213
- P217
- P229
- P233
- P241
- P246
- P265
- P297
- P309
- P364
- P368
- P371
- P381
- P383
- P401
- P443
- P451
- P454
- P457
- P465
- P466
- P467
- P484
- P495
- P499
- P502
- P512
- P516
- P521
- P529
- P541
- P553
- P561
- P576
- P583
- P586
- P606
- P607
- P609
- P614
- P620
- P635
- P641
- P651
- P660
- P670
- P677
- P678
- P686
- P691
- P692
- P701
- P702
- P703
- P704
- P710
- P715
- P739
- P744
- P755
- P779
- P788
- P790
- P806
- P807
- P809
- P815
- P817
- P818
- P821
- P822
- P829
- P830
- P834
- P835
- P836
- P837
- P839
- P842
- P846
- P848
- P849
- P850
- P851
- P852
- P853
- P855
- P859
- P863
- P864
- P865
- P866
- P867
- P868
- P869
- P870
- P871
- P872
- P873
- P874
- P875
- P877
- P879
- P880
- P881
- P882
- P883
- P884
- P885
- P886
- P887
- P888
- P891
- P894
- P896
- P898
- P899
- P903
- P904
- P906
- P907
- P908
- P910
- P914
- P915
- P917
- P919
- P921
- P924
- P925
- P926
- P928
- P931
- P932
- P933
- P935
- P937
- P939
- P941
- P944
- P946
- P947
- P951
- P952
- P953
- P954
- P955
- P956
- P957
- P958
- P959
- P960
- P963
- P964
- P965
- P966
- P967
- P970
- P972
- P973
- P974
- P975
- P976
- P977
- P978
- P980
- P981
- P982
- P983
- P984
- P985
- P986
- P987
- P988
- P989
- P990
- P991
- P993
- P994
- P995
- P996
- P997
- P998
- P999
- P1000
- P1002
- P1003
- P1004
- P1006
- P1007
- P1014
- P1015
- P1016
- P1017
- P1018
- P1020
- P1023
- P1024
- P1025
- P1026
- P1030
- P1031
- P1034
- P1035
- P1037
- P1038
- P1040
- P1041
- P1042
- P1043
- P1044
- P1045
- P1048
- P1049
- P1051
- P1052
- P1053
- P1055
- P1057
- P1058
- P1059
- P1062
- P1063
- P1066
- P1067
- P1070
- P1071
- P1073
- P1074
- P1075
- P1078
- P1085
- P1089
- P1090
- P1091
- P1092
- P1093
- P1095
- P1098
- P1099
- P1104
- P1107
- P1110
- P1114
- P1115
- P1117
- P1120
- P1124
- P1128
- P1131
- P1132
- P1133
- P1134
- P1135
- P1139
- P1140
- P1143
- P1149
- P1153
- P1154
- P1160
- P1162
- P1163
- P1165
- P1177
- P1178
- P1180
- P1183
- P1184
- P1187
- P1190
- P1204
- P1211
- P1218
- P1221
- P1263
- P1276
- P1278
- P1319
- P1329
- P1352
- P1357
- P1358
- P1363
- P1366
- P1373
- P1383
- P1389
- P1390
- P1396
- P1397
- P1414
- P1415
- P1416
- P1417
- P1425
- P1427
- P1428
- P1429
- P1430
- P1431
- P1432
- P1443
- P1464
- P1469
- P1495
- P1501
- P1502
- P1505
- P1508
- P1511
- P1514
- P1519
- P1527
- P1528
- P1547
- P1557
- P1562
- P1564
- P1575
- P1576
- P1595
- P1621
- P1662
- P1663
- P1670
- P1678
- P1718
- P1724
- P1725
- P1730
- P1741
- P1780
- P1829
- P1830
- P1897
- P1928
- P1954
- P1965
- P1966
- P1981
- P2012
- P2036
- P2063
- P2073
- P2075
- P2098
- P2109
- P2110
- P2120
- P2131
- P2135
- P2142
- P2147
- P2173
- P2198
- P2211
- P2227
- P2232
- P2249
- P2258
- P2273
- P2295
- P2309
- P2346
- P2385
- P2386
- P2419
- P2433
- P2465
- P2492
- P2496
- P2503
- P2513
- P2516
- P2552
- P2553
- P2571
- P2576
- P2577
- P2589
- P2607
- P2623
- P2655
- P2665
- P2666
- P2670
- P2681
- P2722
- P2725
- P2730
- P2738
- P2750
- P2784
- P2797
- P2800
- P2813
- P2836
- P2841
- P2853
- P2860
- P2863
- P2893
- P2918
- P2923
- P2929
- P2933
- P2934
- P2938
- P2949
- P2953
- P2956
- P2964
- P2974
- P2975
- P2982
- P2983
- P2996
- P2997
- P2998
- P2999
- P3007
- P3008
- P3009
- P3013
- P3015
- P3021
- P3029
- P3053
- P3056
- P3057
- P3058
- P3060
- P3065
- P3070
- P0140
- P3082
- P3083
- P3090
- P0141
- P3093
- P3094
- P3106
- P3108
- P3116
- P3119
- P3121
- P3122
- P3124
- P3125
- P3129
- P3130
- P3133
- P3147
- P3148
- P3149
- P3150
- P3151
- P3152
- P3154
- P3157
- P3160
- P3173
- P3179
- P3180
- P3181
- P3185
- P3186
- P3190
- P3191
- P3192
- P3217
题目标签
- 语言基础
- 109
- 竞赛
- 82
- 循环语句
- 71
- 其他
- 56
- 年份
- 56
- USACO
- 48
- 字符串
- 41
- 数据结构
- 37
- 字符数组
- 36
- 搜索
- 34
- NOIP
- 32
- 动态规划
- 31
- 一维数组
- 30
- 选择语句
- 28
- 二维数组
- 27
- 贪心
- 23
- 一本通
- 23
- 模拟
- 22
- 普及组
- 19
- 线段树
- 18