C++棋类小游戏2

今天给大家带来我花了1周时间自创的小游戏的升级版,博主还是一名小学生,希望大家提提意见。这是我写的最长的C++代码,希望大家喜欢,不要抄袭,任何编译器都可以。 

以前版本——C++自创棋类小游戏-CSDN博客

C++内容提示:

system("cls");

1.system("cls");是在以下代码出现了很多次,system("cls")意思是清空屏幕。

2.system("color xx);是改变字体及背景颜色,前一个x代表一个数字,可以改变背景颜色,后一个x代表一个数字,可以改变字体颜色 ,但都是根据颜色表来的。

记住:要加头文件:#include<windows.h>
颜色对照表: 
0 = 黑色
1 = 蓝色
2 = 绿色
3 = 湖蓝色
4 = 红色
5 = 紫色
6 = 黄色
7 = 白色
8 = 灰色
9 = 亮蓝色
A = 亮绿色
B = 亮湖蓝色
C = 亮红色
D = 亮紫色
E = 亮黄色
F = 亮白色 

例子:

#include<bits/stdc++.h>
#include<windows.h> 
using namespace std;
int main(){system("color 01");cout<<"1234567890"; return 0;
}

输出结果:

 

当然了,也可以用:

SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 0x02);

具体就不在讲了。

 3.想要在做C++小游戏里实现等待效果,可以用Sleep。

Sleep函数可以使计算机程序(进程,任务或线程)进入休眠,使其在一段时间内处于非活动状态。

一般需要头文件include<windows.h>。

注意"Sleep"首字母要大写,小括号内参数单位是毫秒。

下面这个示例程序可以帮助你了解一下这个函数:

#include <windows.h>  //需要的头文件int main(void)
{Sleep(1000);    //单位,毫秒 (在VC中Sleep中的第一个英文字符为大写的"S")}

注意:

1.用万能头文件不管用了,要包含windows头文件:

#include<windows.h>
2.n可以自由更改,但不要太大,否则容易卡住。

3.Sleep函数一定要大写,否则不管用,会报错。

关于Sleep函数使用
Windows下是大写字母开头的Sleep(),单位为毫秒,linux下面是小写的sleep()。Linux下的sleep()函数是以秒为单位的,sleep(1)就是休眠1毫秒,想实现更短的休眠,linux下有usleep()函数。

记住,Sleep函数中()内只能是数字!

4.MessageBox 

MessageBox指的是显示一个模态对话框,其中包含一个系统图标、 一组按钮和一个简短的特定于应用程序消息,如状态或错误的信息。消息框中返回一个整数值,该值指示用户单击了哪个按钮。

这是MessageBox函数的标准格式之一,本人喜欢用这种格式,注意函数的大小写!

MessageBox不在 #include<bits/stdc++.h> 头文件里面,在 #include<windows.h> 里面!

MB_OK:只有一个按键,即确定

MB_ABORTRETRYIGNORE:有三个按键,分别是中止、重试和忽略

MB_OKCANCEL:有两个按键,确定和取消

例子:

#include<bits/stdc++.h>
#include<windows.h>
using namespace std;int main(){MessageBox(NULL,"你好,我是喷火龙","提示",MB_OK);return 0;}

下面就是游戏代码了: 

#include<windows.h>
#include<conio.h>
#include<bits/stdc++.h>
#include <stdlib.h>
using namespace std;
#define Forij(x) for(int i=1;i<=x;i++) for(int j=1;j<=x;j++)
#define N 25 
int v;
char* u;
int cnt1=0,cntt=0,cnt2=100,ab[1005],mina=100,jl=1;
int huo1=5,huo2=10,huo3=15,huo4=40;
int jie1=4,jie2=15,jie3=10,jie4=50;
int miao1=6,miao2=9,miao3=16,miao4=45;
int pi1=5,pi2=11,pi3=18,pi4=48;
int lie1=20,lie2=50,lie3=60,lie4=100;
int chao1=50,chao2=80,chao3=100,chao4=200; 
int fx[4][2]={{1,1},{1,0},{0,1},{1,-1}};
int Q,GG;
string C[20]={"●","○","﹢","═","║","╔","╚","╗","╝","·"};
void color(int a){SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),a);} 
void gotoxy(int x,int y){COORD pos;pos.X=2*x;pos.Y=y;SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos);}
struct Gomoku
{int m[50][50],nx,ny;void reset(){system("cls");memset(m,-1,sizeof(m));color(7);for (int i=1; i<=N; i++){gotoxy(0,i);cout<<C[4]; gotoxy(N+1,i);cout<<C[4];gotoxy(i,0);cout<<C[3]; gotoxy(i,N+1);cout<<C[3];}gotoxy(0,0);cout<<C[5]; gotoxy(0,N+1);cout<<C[6];gotoxy(N+1,0);cout<<C[7]; gotoxy(N+1,N+1);cout<<C[8];color(3);Forij(N){gotoxy(i,j); cout<<C[2];}nx=ny=N/2+1; gotoxy(nx,ny);}void _drop(int x,int i,int j) {m[i][j]=x;gotoxy(i,j);color(15); cout<<C[x];}int check(){Forij(N){for (int Fx=0,tmp,lst,xx,yy; Fx<4; Fx++) if(m[i][j]!=-1){xx=i,yy=j,tmp=0,lst=m[i][j];for (int k=1; k<=5; k++){if (xx>N || yy>N) break;if (m[xx][yy]==(lst^1)){break;}if (m[xx][yy]==lst) tmp++;xx+=fx[Fx][0],yy+=fx[Fx][1];}if (tmp==5){return lst;}}}return -1;}int arnd(int x,int y){int cnt=0;for (int i=x-1; i<=x+1; i++) if (i>0 && i<=N)for (int j=y-1; j<=y+1; j++) if (j>0 && j<=N)if (m[i][j]>-1) cnt++;}void get_val(int x,int y,int &val){val=0;Forij(N){for (int Fx=0,tmp,tk,xx,yy; Fx<4; Fx++){xx=i,yy=j,tmp=tk=0;for (int k=1; k<=5; k++){if (xx>N || yy>N){tmp=0; break;}if (m[xx][yy]==(x^1)){tmp=0; break;}if (m[xx][yy]==x) tmp++,tk+=(1<<(k-1));xx+=fx[Fx][0],yy+=fx[Fx][1];}switch(tmp){case 5:val+=800000000; break; case 4:val+=1000+350*y; break;case 3:val+=(tk==14)?(300+600*y):(300+200*y); break;case 2:val+=3+2*y; break;case 1:val+=1+y; break;}}}}void AI(int x){int best,brnd,bi,bj,v1,v2,kkk;best=-2147483647;brnd=-2147483647;Forij(N) if (m[i][j]==-1){m[i][j]=x;get_val(x,10,v1);get_val(x^1,80,v2);if (v1-v2>best) bi=i,bj=j,best=v1-v2;if (v1-v2==best)if ((kkk=arnd(i,j))>brnd)brnd=kkk,bi=i,bj=j;m[i][j]=-1;}_drop(x,bi,bj);}void HM(int x){char ch=getch();bool t=224;for (;;ch=getch()){if (ch=='w'||ch=='W'||ch==72&&t) {if (ny>1) ny--;}else if (ch=='s'||ch=='S'||ch==80&&t) {if (ny<N) ny++;}else if (ch=='a'||ch=='A'||ch==75&&t) {if (nx>1) nx--;}else if (ch=='d'||ch=='D'||ch==77&&t) {if (nx<N)nx++;}else if ((ch==32&&t||ch==13&&t)&&m[nx][ny]==-1){_drop(x,nx,ny); return;}gotoxy(nx,ny);}}
} A;
class Chessboard;
class Chess
{
private:int Id;
public:Chess(int x) :Id(x) {}int Get()                {return Id;}virtual bool Judgement(Chessboard& ch, int startx, int starty, int endx, int endy) = 0;virtual ~Chess() {}
};
class Chessboard
{
private:Chess *c[10][11];       char Chessword[15][4] = { "兵","炮","车","马","相","仕","帅"," ","将","士","象","馬","車","砲","卒" };
public:static int Player;       static bool End;         Chessboard();Chess *Get(int x, int y);int Getid(int x, int y);bool Move(int startx, int starty, int endx, int endy);	void Init();               void Show();              void Play();              ~Chessboard();
};
class General :public Chess
{
public:General(int i) :Chess((i == 0 ? -1 : 1)) {}bool Judgement(Chessboard& ch, int startx, int starty, int endx, int endy){int TempX = startx - endx;int TempY = starty - endy;int S_Id = ch.Getid(startx, starty);int E_Id = ch.Getid(endx, endy);if ((S_Id*E_Id <= 0) && (TempX*TempX + TempY * TempY == 1) && (endx >= 4 && endx <= 6) && (endy >= 1 && endy <= 3 || endy >= 8 && endy <= 10)){return true;}return false;}~General(){Chessboard::End = false;}
};
class BodyGuard :public Chess
{
public:BodyGuard(int i) :Chess((i == 0 ? -2 : 2)) {}bool Judgement(Chessboard& ch, int startx, int starty, int endx, int endy){int TempX = startx - endx;int TempY = starty - endy;int S_Id = ch.Getid(startx, starty);int E_Id = ch.Getid(endx, endy);if ((S_Id*E_Id <= 0) && (TempX*TempX + TempY * TempY == 2) && (endx >= 4 && endx <= 6) && (endy >= 1 && endy <= 3 || endy >= 8 && endy <= 10)){return true;}return false;}
};
class Chancellor :public Chess
{
public:Chancellor(int i) :Chess((i == 0 ? -3 : 3)) {}bool Judgement(Chessboard& ch, int startx, int starty, int endx, int endy){int TempX = startx - endx;int TempY = starty - endy;int S_Id = ch.Getid(startx, starty);int E_Id = ch.Getid(endx, endy);if ((S_Id*E_Id <= 0) && (TempX*TempX + TempY * TempY == 8) && (endx % 2 != 0 && endx >= 1 && endy <= 9) && ((starty - 1) / 5 == (endy - 1) / 5) && !ch.Get(startx + (TempX / 2), starty + (TempY / 2))){return true;}return false;}
};
class Horse :public Chess
{
public:Horse(int i) :Chess((i == 0 ? -4 : 4)) {}bool Judgement(Chessboard& ch, int startx, int starty, int endx, int endy){int TempX = startx - endx;int TempY = starty - endy;int S_Id = ch.Getid(startx, starty);int E_Id = ch.Getid(endx, endy);if ((S_Id*E_Id <= 0) && (TempX*TempX + TempY * TempY == 5) && !ch.Get(startx + (TempX / 2), starty + (TempY / 2))){return true;}return false;}
};
class Chariot :public Chess
{
public:Chariot(int i) :Chess((i == 0 ? -5 : 5)) {}bool Judgement(Chessboard& ch, int startx, int starty, int endx, int endy){int TempX = startx - endx;int TempY = starty - endy;int S_Id = ch.Getid(startx, starty);int E_Id = ch.Getid(endx, endy);if ((S_Id*E_Id <= 0) && (!(TempX&&TempY)) && (TempX + TempY)){if (TempX){int Sign = (TempX > 0 ? -1 : 1);for (int i = 1; i < fabs(TempX); i++){if (ch.Get(startx + Sign * i, starty)){return false;}}}else{int Sign = (TempY > 0 ? -1 : 1);for (int i = 1; i < fabs(TempY); i++){if (ch.Get(startx, starty + Sign * i)){return false;}}}return true;}return false;}
};
class Cannon :public Chess
{
public:Cannon(int i) :Chess((i == 0 ? -6 : 6)) {}bool Judgement(Chessboard& ch, int startx, int starty, int endx, int endy){int TempX = startx - endx;int TempY = starty - endy;int S_Id = ch.Getid(startx, starty);int E_Id = ch.Getid(endx, endy);if ((S_Id*E_Id <= 0) && (!(TempX&&TempY)) && (TempX + TempY)){int Tmp = 0;if (TempX){int Sign = (TempX > 0 ? -1 : 1);for (int i = 1; i < fabs(TempX); i++){if (ch.Get(startx + Sign * i, starty)){Tmp++;}}}else{int Sign = (TempY > 0 ? -1 : 1);for (int i = 1; i < fabs(TempY); i++){if (ch.Get(startx, starty + Sign * i)){Tmp++;}}}if (E_Id){if (Tmp == 1){return true;}}else{if (!Tmp){return true;}}}return false;}
};
class Soldier :public Chess
{
public:Soldier(int i) :Chess((i == 0 ? -7 : 7)) {}bool Judgement(Chessboard& ch, int startx, int starty, int endx, int endy){int TempX = startx - endx;int TempY = starty - endy;int S_Id = ch.Getid(startx, starty);int E_Id = ch.Getid(endx, endy);if ((S_Id*E_Id <= 0) && (S_Id*TempY <= 0)){if (fabs(TempY) == 1 && TempX == 0){return true;}if (fabs(TempX) == 1 && TempY == 0){if (((starty - 1) / 5 == 0 && S_Id < 0) || ((starty - 1) / 5 == 1 && S_Id > 0)){return true;}}}return false;}
};
int Chessboard::Player = -1;
bool Chessboard::End = true;
inline Chessboard::Chessboard()
{memset(c, NULL, sizeof(c));
}
inline Chess * Chessboard::Get(int x, int y)
{return c[x][y];
}
int Chessboard::Getid(int x, int y)
{if (c[x][y] != NULL){return c[x][y]->Get();}return NULL;
}
bool Chessboard::Move(int startx, int starty, int endx, int endy)
{if (startx >= 1 && startx <= 9 && starty >= 1 && starty <= 10 && endx >= 1 && endx <= 9 && endy >= 1 && endy <= 10 && Getid(startx, starty) && Getid(startx, starty)*Player > 0 && c[startx][starty]->Judgement(*this, startx, starty, endx, endy)){if (c[endx][endy] != NULL){delete c[endx][endy];           }c[endx][endy] = c[startx][starty];c[startx][starty] = NULL;Player *= -1;                       return true;}else{cout << "走法错误,请重新输入:" << endl;return false;}
}
void Chessboard::Init()
{c[1][1] = new Chariot(1);c[9][1] = new Chariot(1);c[2][1] = new Horse(1);c[8][1] = new Horse(1);c[3][1] = new Chancellor(1);c[7][1] = new Chancellor(1);c[4][1] = new BodyGuard(1);c[6][1] = new BodyGuard(1);c[5][1] = new General(1);c[2][3] = new Cannon(1);c[8][3] = new Cannon(1);c[1][4] = new Soldier(1);c[3][4] = new Soldier(1);c[5][4] = new Soldier(1);c[7][4] = new Soldier(1);c[9][4] = new Soldier(1);c[1][10] = new Chariot(0);c[9][10] = new Chariot(0);c[2][10] = new Horse(0);c[8][10] = new Horse(0);c[3][10] = new Chancellor(0);c[7][10] = new Chancellor(0);c[4][10] = new BodyGuard(0);c[6][10] = new BodyGuard(0);c[5][10] = new General(0);c[2][8] = new Cannon(0);c[8][8] = new Cannon(0);c[1][7] = new Soldier(0);c[3][7] = new Soldier(0);c[5][7] = new Soldier(0);c[7][7] = new Soldier(0);c[9][7] = new Soldier(0);
}
void Chessboard::Show()
{cout << endl;HANDLE handle;handle = GetStdHandle(STD_OUTPUT_HANDLE);SetConsoleTextAttribute(handle, 0xF0);cout << "     P2  一 二 三 四 五 六 七 八 九" << endl << endl;char num[11][4] = { "零","一","二","三","四","五","六","七","八","九" ,"十" };for (int i = 1; i < 11; i++){if (i == 6){SetConsoleTextAttribute(handle, 0xF0);cout << "          ————楚河 汉界————" << endl << endl;}SetConsoleTextAttribute(handle, 0xF0);cout << "     " << num[i] << "  ";for (int j = 1; j < 10; j++){if (c[j][i] != NULL){if (c[j][i]->Get() > 0){SetConsoleTextAttribute(handle, 0xF2);cout << Chessword[c[j][i]->Get() + 7] << " ";}else{SetConsoleTextAttribute(handle, 0xFC);cout << Chessword[c[j][i]->Get() + 7] << " ";}}else if ((i == 2 && j == 5) || (i == 9 && j == 5)){SetConsoleTextAttribute(handle, 0xF0);cout << "米" << " ";}else{SetConsoleTextAttribute(handle, 0xF0);cout << "十" << " ";}}cout << endl << endl;}SetConsoleTextAttribute(handle, 0xF0);cout << "     P1  一 二 三 四 五 六 七 八 九" << endl << endl;
}
void Chessboard::Play()
{HANDLE handle;handle = GetStdHandle(STD_OUTPUT_HANDLE);SetConsoleTextAttribute(handle, 0xFC);system("cls");this->Init();this->Show();do{int startx, starty, aimx, aimy, iflag;int sid, aid;iflag = 0;do{sid = aid = 0;if ((Chessboard::Player == 1 ? 2 : 1) == 1){SetConsoleTextAttribute(handle, 0xFC);}else{SetConsoleTextAttribute(handle, 0xF2);}cout << "请P" << (Chessboard::Player == 1 ? 2 : 1) << "输入起始棋子位置与目标位置的坐标:" << endl;cin >> startx >> starty >> aimx >> aimy;} while (!this->Move(startx, starty, aimx, aimy));system("cls");this->Show();for (int i = 4; i < 7; i++){for (int j = 1; j < 11; j++){if (c[i][j] != NULL){if ((int)fabs(c[i][j]->Get()) == 1){iflag++;}else if (iflag != 0 && iflag != 2){if ((int)fabs(c[i][j]->Get()) != 1){iflag--;}}}}}if (iflag == 2){Player *= -1;Chessboard::End = false;}} while (Chessboard::End);if ((Chessboard::Player == 1 ? 1 : 2) == 1){SetConsoleTextAttribute(handle, 0xFC);}else{SetConsoleTextAttribute(handle, 0xF2);}cout << "结束,赢家是Player" << (Chessboard::Player == 1 ? 1 : 2) << endl;}
Chessboard::~Chessboard()
{for (int i = 0; i < 10; i++){for (int j = 0; j < 11; j++){if (c[i][j] != NULL){delete c[i][j];c[i][j] = NULL;}}}
}
void slowout(char *p)
{while(1){if(*p!=0){printf("%c",*p++);}else{break;}Sleep(100);}cout<<endl;
}
int main()
{const int n=19,rangzi=7;int x,y,turn,a[101][101],vis[101][101],vist[101][101],ans,p;char g;bool flag;int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};system("color 74");Sleep(25); system("color 04");Sleep(25); system("color 74");Sleep(25); system("color 04");Sleep(25); system("color 74");Sleep(25); system("color 04");Sleep(25); system("color 74");Sleep(25); system("color 04");Sleep(25); system("color 74");Sleep(25); system("color 04");Sleep(25);  slowout("棋类游戏即将开始,请做好准备!!!");cout<<"欢迎来到棋类世界\n";cout<<"请问您的姓名是_____?\n";string a1;cin>>a1;cout<<"你好"<<a1<<endl;int jn=0;//ji nengint fanhui;int money=10;int gy;int gy2; int hq;int yonghu;int mima;int dj;//dao juint slk=0;//sheng li kaint jqk=0;//jia qian kaint jhk=0;//ji hui kaint start=0;cout<<"----------------------------\n";cout<<"|          棋类游戏        |\n";cout<<"|        0.“游客”        |\n";cout<<"|        1.普通VIP         |\n";cout<<"|        2.黄金VIP         |\n"; cout<<"----------------------------\n";cin>>gy2;if(gy2==0){cout<<"身份:游客"<<endl; }if(gy2==1){cout<<"请输入密码"<<endl;cin>>mima;if(mima==5963){cout<<"登入成功"<<endl;cout<<"身份:普通VIP"<<endl; }else{cout<<"密码错误"<<endl;cout<<"身份:游客"<<endl; }	}if(gy2==2){cout<<"请输入密码"<<endl;cin>>mima;if(mima==520520){cout<<"登入成功"<<endl;cout<<"身份:黄金VIP"<<endl; }else{cout<<"密码错误"<<endl;cout<<"身份:游客"<<endl; }	} Sleep(1000); system("cls");slowout("抵制不良游戏,拒绝盗版游戏。"); slowout("注意自我保护,谨防受骗上当。");slowout("适度游戏益脑,沉迷游戏伤身。");slowout("合理安排时间,享受健康生活。");slowout("…+……loading……+……loading……+……loading……+……loading……+……");Sleep(1000); system("pause");system("cls"); int sy;//shi yong while(1){cout<<"-------------------------------\n";cout<<"|          棋类游戏           |\n";cout<<"|        0.退出               |\n";cout<<"|        1.人机对战           |\n";cout<<"|        2.双人对战(待开发)   |\n";cout<<"|        3.猜数游戏(单人)     |\n"; cout<<"|        4.猜数游戏(人机&多人)|\n"; cout<<"|        5.玩完五子棋关机     |\n"; cout<<"|        6.象棋               |\n";cout<<"|        7.道具商店           |\n"; cout<<"|        8.VIP商店            |\n";cout<<"|        9.技能对战           |\n";cout<<"|        作者:喷火龙         |\n"; cout<<"-------------------------------\n";if(jqk>0){cout<<"是否使用加钱卡?"<<endl;cout<<"1.使用 | 2.不用"<<endl;cin>>sy;if(sy==1){jqk-=1;cout<<"购买成功!"<<endl; system("cls");}else{cout<<"继续"<<endl; system("cls");}}cout<<"请选择"<<endl;int xx;cin>>xx;slowout("…+……loading……+……loading……+……loading……+……");if(xx==0){SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 0x06);return 0;}if(xx==1){ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 0x01);if(slk>0){cout<<"是否使用胜利卡?"<<endl;cout<<"1.使用 | 2.不用"<<endl;cin>>sy;if(sy==1){slk--;cout<<"使用成功"<<endl; Sleep(2000);cout<<"\a";printf("你赢了一局!");money+=2;start+=0.5;system("cls");}if(sy==2){cout<<"继续"; }}system("cls");cout<<"你想玩几局(范围:1000):"<<endl;cin>>v;if(v>1000){cout<<"It's too long!!!"<<endl;cout<<"Your Computer is broke!"<<endl;system("pause");cout<<"你想玩几局(范围:1000):"<<endl;cin>>v;if(v>1000){cout<<"It's too long!!!"<<endl;cout<<"Your Computer is broke";cout<<"我必须给你惩罚!!!";for(int j=1;j<=5;j++){system("color 00");cout<<"哈哈!!!"<<endl; system("color 01");cout<<"哈哈!!!"<<endl; system("color 02");cout<<"哈哈!!!"<<endl; system("color 03");cout<<"哈哈!!!"<<endl; system("color 04");cout<<"哈哈!!!"<<endl; system("color 05");cout<<"哈哈!!!"<<endl; system("color 06");cout<<"哈哈!!!"<<endl; system("color 07");cout<<"哈哈!!!"<<endl; system("color 08");cout<<"哈哈!!!"<<endl; system("color 09");cout<<"哈哈!!!"<<endl; Sleep(50);}}} else{for (int i=1;i<=v;i++){A.reset();for (GG=-1;;){gotoxy(A.nx,A.ny);A.HM(0); GG=A.check(); if (GG>-1) break;A.AI(1); GG=A.check(); if (GG>-1) break;}gotoxy(5,N+3);if (GG==0) {Sleep(2000);cout<<"\a";printf("你侥幸赢了一局!");money+=2;start+=0.5;cout<<"是否返回主页,1=是,2=否"<<endl;cin>>fanhui; if(fanhui==1){system("cls");} else{cout<<"继续"<<endl;system("cls");}}if (GG==1) {Sleep(2000);cout<<"\a";printf("喷火龙的人工智障赢了!");cout<<"是否返回主页,1=是,2=否"<<endl;cin>>fanhui; if(fanhui==1){system("cls");} else{cout<<"继续"<<endl;system("cls");}} while (kbhit()) getch();Sleep(2000);gotoxy(5,N+3);system("pause"); }}}if(xx==2){SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 0x03);cout<<"待开发,敬请期待!!!"<<endl; cout<<"想玩人机输1"<<endl; cout<<"不想玩输0"<<endl; int t;cin>>t;if(t==1){A.reset();for (GG=-1;;){gotoxy(A.nx,A.ny);A.HM(0); GG=A.check(); if (GG>-1) break;A.AI(1); GG=A.check(); if (GG>-1) break;}gotoxy(5,N+3);if (GG==0) {Sleep(2000);system("cls");cout<<"\a";printf("你侥幸赢了一局!");money+=2;start+=0.5;cout<<"是否返回主页,1=是,2=否"<<endl;cin>>fanhui; if(fanhui==1){system("cls");} else{cout<<"继续"<<endl;system("cls");}} if (GG==1) {Sleep(2000);system("cls");cout<<"\a";printf("喷火龙的人工智障赢了!");cout<<"是否返回主页,1=是,2=否";cin>>fanhui; if(fanhui==1){system("cls");} else{cout<<"继续"<<endl;system("cls");}}while (kbhit()) getch();Sleep(2000);gotoxy(5,N+3);system("pause"); }else{cout<<"by~";cout<<"作者:喷火龙"<<endl; return 0;}}	if(xx==3){SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 0x05);cout<<"猜数";cout<<endl;cout<<"猜数游戏(1-100)"<<endl;cout<<"1.普通人员"<<endl;cout<<"2.VIP1"<<endl;cout<<"3.VIP2"<<endl;int qd;cin>>qd;int mm;int mm2;int mm3;int vip;if(qd==1){mm=10;}if(qd==2){cout<<"请输入密码:";cin>>mm2;if(mm2==5963){MessageBox(NULL,"你好,我是喷火龙,密码正确,VIP1模式,生命+10!!!","提示",MB_OK);mm=20; }if(mm2!=5963){MessageBox(NULL,"你好,我是喷火龙,密码错误!!!","提示",MB_OK);system("cls");mm=10; system("pause");cout<<"游戏继续"<<endl; }} if(qd==3){cout<<"请输入密码:";cin>>mm3;if(mm3==520520){MessageBox(NULL,"你好,我是喷火龙,密码正确,VIP2模式,请自定义生命数(猜几次)!!!","提示",MB_OK);cin>>mm;}if(mm3!=520520){MessageBox(NULL,"你好,我是喷火龙,密码错误!!!","提示",MB_OK);system("cls");mm=10; system("pause");cout<<"游戏继续"<<endl;}}system("cls");if(jhk>0){cout<<"是否使用机会卡?"<<endl;cout<<"1.使用 | 2.不用"<<endl;cin>>sy;if(sy==1){jhk-=1;cout<<"使用成功!"<<endl; mm+=3;jhk--; system("cls");}else{cout<<"继续"<<endl; system("cls");}}srand(time(NULL));int key=rand()%100+1;for(int i=1;i<=mm;i++){int x;cout<<"请输入一个数字:";cin>>x;if(x>100||x<1){cout<<"浪费机会!!!"; }if(x<key){cout<<"小了"<<endl;} if(x>key){cout<<"大了"<<endl;} if(x==key){SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 0x02);cout<<"恭喜您,猜对啦!"<<endl;money++; start++;cout<<"是否返回主页,1=是,2=否";cin>>fanhui; if(fanhui==1){system("cls");} else{cout<<"继续"<<endl;system("cls");}} }cout<<"10次机会已用完,很遗憾,未猜对!"<<endl;cout<<"正确数字是:"<<key<<endl;Sleep(1000);system("cls");cout<<"是否返回主页,1=是,2=否"<<endl;cin>>fanhui; if(fanhui==1){system("cls");} else{cout<<"继续"<<endl;system("cls");}}if(xx==4){SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 0x07);int n,m;bool c[100005];cout<<"猜数";cout<<endl;srand(time(NULL));cout<<"==============================================================\n几人猜数(只支持100000人以内)??";cin>>n;cout<<"==============================================================\n0~几???";cin>>m;for(;;){cout<<"==============================================================\n开始!!!";int x=rand()%(m+1),y,h=0,e=m,t=rand()%n;bool hh=1,ee=1;do{cout<<"\n==============================================================\n";cout<<h<<"~"<<e<<endl;++t;t-=t>n?n:0;if(!c[t])cout<<t<<"号猜(电脑帮猜 输1 ,设置TA为电脑 输2):",cin>>y;if(y==2)c[t]=1;if(y==1||c[t]){y=(h+e)/2;cout<<"帮"<<t<<"号猜猜成"<<y<<endl;if(y==x)break;if(y>x){cout<<"大了";e=y; continue;}if(y<x){cout<<"小了";h=y; continue;}} if(y<=h||y>=e){cout<<"浪费机会!!!";continue;if(!h&&!y)if(hh)hh=0;else{cout<<"浪费机会!!!";continue;}if(e==m&&y==m)if(ee)ee=0;else{cout<<"浪费机会!!!";continue;}}if(y>x){cout<<"大了";e=y; }if(y<x){cout<<"小了";h=y; }}while(x!=y);cout<<t<<"号赢了!!!\n==============================================================\n再来一局吗?\ny/n\n";char a;a=getch();if(a=='n'||a=='N')break; }getchar();cout<<"==============================================================\nbyebye!\n==============================================================\n双击任意键结束,单机空格关机!";char a=getch();if(a==' '){cout<<"\n确定吗??确定点空格一下,否则双击任意键结束。";a=getch();if(a==' ')system("shutdown -s -t 0");}if(xx==5){	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 0x01);cout<<"范围(1~1000)你想玩几局:"<<endl;cin>>v;if(v>1000){cout<<"It's too long!!!"<<endl;cout<<"Your Computer is broke"<<endl;system("pause");cout<<"范围(1~1000)你想玩几局:"<<endl;cin>>v;if(v>1000){cout<<"It's too long!!!"<<endl;cout<<"Your Computer is broke."<<endl;cout<<"我必须给你惩罚!!!";cout<<"你的money-1,start-0.5"<<endl; money-=1;start-=0.5;}system("cls");	}else{MessageBox(NULL,"你好,我是喷火龙,玩完游戏你的电脑就会关机,请保存好其它东西!!!","提示",MB_OK);for (int i=1;i<=v;i++){A.reset();for (GG=-1;;){gotoxy(A.nx,A.ny);A.HM(0); GG=A.check(); if (GG>-1) break;A.AI(1); GG=A.check(); if (GG>-1) break;}gotoxy(5,N+3);if (GG==0) {Sleep(2000);cout<<"\a";printf("你侥幸赢了一局!");money+=2;cout<<"是否返回主页,1=是,2=否"<<endl;cin>>fanhui; if(fanhui==1){system("cls");} else{cout<<"继续"<<endl;system("cls");}}if (GG==1) {Sleep(2000);system("cls");cout<<"\a";printf("喷火龙的人工智障赢了!");cout<<"是否返回主页,1=是,2=否"<<endl;cin>>fanhui; if(fanhui==1){system("cls");} else{cout<<"继续"<<endl;system("cls");}} while (kbhit()) getch();Sleep(2000);gotoxy(5,N+3);system("pause"); }}}system("cls");if(MessageBox(NULL,"即将关机,最后确定一下","提示",MB_YESNO)==IDYES){  Sleep(2000); system ("shutdown -p");	}else return 0;	}if(xx==6){SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 0x0C);if(MessageBox(NULL,"是否找到另一个玩家?","提示",MB_YESNO)==IDYES){  Sleep(1000); cout<<"象棋游戏开始(横着的数字在前,竖着的数字在后。)"<<endl;Sleep(4000);Chessboard C;C.Play();system("pause");}else{cout<<"请找到一个对手吧!"<<endl;return 0;}}if(xx==7){cout<<"-------------------------------\n";cout<<"|              道具           |\n";cout<<"|            物品       价格  |\n"; cout<<"|    0.退出商店        | 无   |\n"; cout<<"|    1.胜利卡(直接胜利)| 3$   |\n";cout<<"|    2.加钱卡(获得10$) | 2☆  |\n";cout<<"|    3.机会卡(多猜3次) | 3$   |\n"; cout<<"-------------------------------\n";cout<<"你的money:"<<money<<" "<<endl;cout<<"你的start:"<<start<<" "<<endl; cout<<"要买啥?"<<endl;cin>>dj; if(dj==0){cout<<"成功退出"<<endl;system("cls");cout<<"是否返回主页,1=是,2=否"<<endl;cin>>fanhui; if(fanhui==1){system("cls");} else{cout<<"继续"<<endl;system("cls");}} if(dj==1){if(money>=3){money-3;cout<<"购买成功!"<<endl;slk++;system("cls");}else{cout<<"money不够。"<<endl;system("cls");}}if(dj==2){if(start>=2){start-2;cout<<"购买成功!"<<endl;jqk++;system("cls");}else{cout<<"start不够。"<<endl;system("cls");}}if(dj==3){if(money>=3){money-3;cout<<"购买成功!"<<endl;jhk++;system("cls");}else{cout<<"money不够。"<<endl;system("cls");}}if(dj>3){cout<<"无效输出。"<<endl;system("cls");}}if(xx==8){cout<<"-------------------------------\n";cout<<"|          棋类游戏           |\n";cout<<"|        0.退出               |\n";cout<<"|        1.普通VIP(1级10$)  |\n";cout<<"|        2.黄金VIP(2级50$)  |\n"; cout<<"-------------------------------\n";cout<<"1.购买VIP";cin>>gy;if(gy==0){cout<<"成功退出"<<endl;system("cls");cout<<"是否返回主页,1=是,2=否"<<endl;cin>>fanhui; if(fanhui==1){system("cls");} else{return 0;} }if(gy==1){cout<<"你的money:"<<money<<endl;cout<<"买哪个VIP,输入0退出";cin>>hq;if(hq==0){cout<<"返回"<<endl;system("cls");} if(hq==1){if(money>=10){money-10;cout<<"VIP1级已购买成功,密码:5963"<<endl;Sleep(1500);system("cls"); }else{cout<<"money不够"<<endl;Sleep(1000);system("cls");}}if(hq==2){if(money>=50){money-50;cout<<"VIP2级已购买成功,密码:520520"<<endl; Sleep(1500);system("cls");}else{cout<<"money不够"<<endl;Sleep(1000);system("cls");}}} }if(xx==9){ cout<<"欢迎来到宝可梦大陆\n";cout<<"1.对战 | 2.商店";int a2;cin>>a2;if(a2==1){if(cntt==0){cout<<"由于您是初次游玩,系统为您准备了三个宝可梦,请选择一个\n";cout<<"1-小火龙 2-杰尼龟 3-妙蛙种子\n";int a3;cin>>a3;if(a3==1){cout<<"恭喜获得小火龙\n"; ab[1]=1;}else if(a3==2){cout<<"恭喜获得杰尼龟\n";ab[2]=1; }else{cout<<"恭喜获得妙蛙种子\n"; ab[3]=1;}cntt=1;}system("cls");if(cnt1<=10){int lena1=3,lena2=4,lena3=7,lenb1=3,lenb2=4,lenb3=7,ji1,ji2,ji3,ji4;cout<<"你的对手是小火龙\n";cout<<"请选择一个宝可梦出战:\n";if(ab[1]==1){cout<<"小火龙 ";}if(ab[2]==1){cout<<"杰尼龟 "; }if(ab[3]==1){cout<<"妙蛙种子 "; }if(ab[5]==1){cout<<"皮卡丘";}if(ab[8]==1){cout<<"裂空座 ";}if(ab[9]==1){cout<<"超梦 ";}cout<<endl;string a7;cin>>a7;system("cls");if(a7=="小火龙"){cout<<"小火龙的技能:\n";cout<<"普通攻击:"<<"-"<<huo1<<endl;cout<<"一技能喷火:"<<"-"<<huo2<<endl;cout<<"二技能火球:"<<"-"<<huo3<<endl;cout<<"大招火焰洗礼:"<<"-"<<huo4<<endl;ji1=huo1;ji2=huo2;ji3=huo3;ji4=huo4;}if(a7=="杰尼龟"){cout<<"杰尼龟的技能:\n";cout<<"普通攻击:"<<"-"<<jie1<<endl;cout<<"一技能水刃:"<<"-"<<jie2<<endl;cout<<"二技能水弹:"<<"-"<<jie3<<endl;cout<<"大招水冲龙门:"<<"-"<<jie4<<endl;ji1=jie1;ji2=jie2;ji3=jie3;ji4=jie4;}if(a7=="妙蛙种子"){cout<<"妙蛙种子的技能:\n";cout<<"普通攻击:"<<"-"<<miao1<<endl;cout<<"一技能草剑:"<<"-"<<miao2<<endl;cout<<"二技能飞花:"<<"-"<<miao3<<endl;cout<<"大招绿意盎然:"<<"-"<<miao4<<endl;ji1=miao1;ji2=miao2;ji3=miao3;ji4=miao4;}if(a7=="皮卡丘"){cout<<"皮卡丘的技能:\n";cout<<"普通攻击:"<<"-"<<pi1<<endl;cout<<"一技能十万伏特:"<<"-"<<pi2<<endl;cout<<"二技能铁尾:"<<"-"<<pi3<<endl;cout<<"大招百万伏特:"<<"-"<<pi4<<endl;ji1=pi1;ji2=pi2;ji3=pi3;ji4=pi4;}if(a7=="裂空座"){cout<<"裂空座的技能:\n";cout<<"普通攻击:"<<"-"<<lie1<<endl;cout<<"一技能甩尾:"<<"-"<<lie2<<endl;cout<<"二技能暴咬:"<<"-"<<lie3<<endl;cout<<"大招恶龙咆哮:"<<"-"<<lie4<<endl;}if(a7=="超梦"){cout<<"超梦的技能:\n";cout<<"普通攻击:"<<"-"<<chao1<<endl;cout<<"一技能暴击:"<<"-"<<chao2<<endl;cout<<"二技能拳击:"<<"-"<<chao3<<endl;cout<<"大招一击必杀:"<<"-"<<chao4<<endl;ji1=chao1;ji2=chao2;ji3=chao3;ji4=chao4;}cout<<"1-普攻 2-一技能 3-二技能 4-大招\n"; int jiu1=5,jiu2=5,minb=100;for(int i=1;i<=1000;i++){if(mina<=0){cout<<"你输了\n";cnt2-=5;break;}if(minb<=0){cout<<"你赢了\n"; cnt2+=50;money+=2;break;}if(minb<=0&&jl>0){cout<<"你赢了\n";cnt2+=60;money+=3;cout<<"你有"<<jl<<"个精灵球是否将它收服?\n";string a10;cin>>a10;if(a10=="是"){cout<<"恭喜获得小火龙\n";ab[1]=1; jl--;}break;}cout<<"第"<<i<<"回合\n";cout<<"你的急救包剩余"<<jiu1<<endl;int a8;srand(time(NULL));a8=rand()%2+1;if(a8==1){cout<<"你是先手\n";cout<<"请选择你要用的技能\n";int a9,a11=0,a12=0,a13=0;cin>>a9;if(a9==1){cout<<"你使用了普攻对方生命-"<<ji1<<endl; minb-=ji1;cout<<"对方生命"<<minb<<endl;}if(a9==2&&lena1>=3){cout<<"你使用了一技能对方生命-"<<ji2<<endl;minb-=ji2;cout<<"对方生命"<<minb<<endl; lena1=0;a11=1;}if(a11=1){lena1++;}if(a9==3&&lena2>=4){cout<<"你使用了二技能对方生命-"<<ji3<<endl;minb-=ji3;lena2=0;a12=1;}if(a12==1){lena2++;}if(a9==4&&lena3>=7){cout<<"你使用了大招对方生命-"<<ji4<<endl;minb-=ji4;lena3=0;a13=1;}if(a13==1){lena3++;}if(jiu2>0){cout<<"对方使用了急救包生命+10\n";minb+=10;cout<<"对方生命"<<minb<<endl;jiu2--;}cout<<"到对方攻击了\n";int c,a14=0,a15=0,a16=0;srand(time(NULL));c=rand()%4+1;if(c==1){cout<<"对方使用了普攻你的生命-5\n";mina-=5; cout<<"你的生命:"<<mina<<endl;}else if(c==2&&lenb1==3){cout<<"对方使用了一技能你的生命-10\n";mina-=10;cout<<"你的生命:"<<mina<<endl;a14=1;lenb1=0;}else if(c==3&&lenb2==4){cout<<"对方使用了二技能你的生命-15\n";mina-=15;cout<<"你的生命:"<<mina<<endl;a15=1;lenb2=0;}else if(c==3&&lenb3==7){cout<<"对方使用了大招你的生命-40\n";minb-=40;cout<<"你的生命:"<<mina<<endl;a16=1;lenb3=0;}else{cout<<"对方使用了普攻你的生命-5\n";mina-=5; cout<<"你的生命:"<<mina<<endl;}if(a14==1){lenb1++;}if(a15==1){lenb2++;}if(a16==1){lenb3++;}if(jiu1>0){if(mina<=20){ cout<<"你有一个急救包是否使用?\n";string a17;cin>>a17;if(a17=="是"){cout<<"使用成功\n";mina+=10;jiu1--;cout<<"你的生命:"<<mina<<endl;}}} }else{cout<<"对方是先手\n";cout<<"到对方攻击了\n";int c,a14=0,a15=0,a16=0;srand(time(NULL));c=rand()%4+1;if(c==1){cout<<"对方使用了普攻你的生命-5\n";mina-=5; cout<<"你的生命:"<<mina<<endl;}else if(c==2&&lenb1==3){cout<<"对方使用了一技能你的生命-10\n";mina-=10;cout<<"你的生命:"<<mina<<endl;a14=1;lenb1=0;}else if(c==3&&lenb2==4){cout<<"对方使用了二技能你的生命-15\n";minb-=15;cout<<"你的生命:"<<mina<<endl;a15=1;lenb2=0;}else if(c==3&&lenb3==7){cout<<"对方使用了大招你的生命-40\n";minb-=40;cout<<"你的生命:"<<mina<<endl;a16=1;lenb3=0;}else{cout<<"对方使用了普攻你的生命-5\n";mina-=5; cout<<"你的生命:"<<mina<<endl;}if(a14==1){lenb1++;}if(a15==1){lenb2++;}if(a16==1){lenb3++;}if(jiu1>0){if(mina<=10){cout<<"你有一个急救包是否使用?\n";string a17;cin>>a17;if(a17=="是"){cout<<"使用成功\n";mina+=10;cout<<"你的生命:"<<mina<<endl;jiu1--;Sleep(500);system("cls");}}}cout<<"请选择你要用的技能\n";int a9,a11=0,a12=0,a13=0;cin>>a9;if(a9==1){cout<<"你使用了普攻对方生命-"<<ji1<<endl; minb-=ji1;cout<<"对方生命"<<minb<<endl;}if(a9==2&&lena1>=3){cout<<"你使用了一技能对方生命-"<<ji2<<endl;minb-=ji1;cout<<"对方生命"<<minb<<endl; lena1=0;a11=1;}if(a11=1){lena1++;}if(a9==3&&lena2>=4){cout<<"你使用了二技能对方生命-"<<ji3<<endl;minb-=ji3;lena2=0;a12=1;}if(a12==1){lena2++;}if(a9==4&&lena3>=7){cout<<"你使用了大招对方生命-"<<ji4<<endl;minb-=ji4;lena3=0;a13=1;}if(a13==1){lena3++;}if(jiu2>0){cout<<"对方使用了急救包生命+10\n";minb+=10;cout<<"对方生命"<<minb<<endl;jiu2--;}}Sleep(1000);system("cls");}}}if(a2==2){cout<<"你的钱:"<<cnt2<<endl;cout<<"1.皮卡丘-200金币\n";cout<<"2.小火龙-200金币\n";cout<<"3.杰尼龟-200金币\n";cout<<"4.妙蛙种子-200金币\n";cout<<"5.裂空座-1000金币\n";cout<<"6.超梦-非卖品(测试使用)\n"; cout<<"请选购\n";int a6;cin>>a6;if(a6==1&&cnt2>=200){cout<<"购买成功\n";cout<<"恭喜获得皮卡丘\n";cnt2-=200;ab[5]=1;system("cls");Sleep(500);}if(a6==2&&cnt2>=200){cout<<"购买成功\n";cout<<"恭喜获得小火龙\n";cnt2-=200;ab[1]=1;system("cls");Sleep(500);}if(a6==3&&cnt2>=200){cout<<"购买成功\n";cout<<"恭喜获得杰尼龟\n";cnt2-=200;ab[2]=1;system("cls");Sleep(500);}if(a6==4&&cnt2>=200){cout<<"购买成功\n";cout<<"恭喜获得妙蛙种子\n";cnt2-=200;ab[3]=1;system("cls");Sleep(500);}if(a6==5&&cnt2>=1000){cout<<"购买成功\n";cout<<"恭喜获得裂空座\n";cnt2-=1000;ab[8]=1;system("cls");Sleep(500);}if(a6==6){int virgo=0;cout<<"密码:";cin>>virgo;if(virgo==5963){cout<<"正确!!!"<<endl;ab[9]=1;cout<<"恭喜获得超梦\n";}else{cout<<"错误!!!"<<endl; }Sleep(500);system("cls");} else{system("cls");}}if(xx>10){cout<<"超出范围"<<endl;if(MessageBox(NULL,"是否回到主页面???","询问",MB_YESNO)==IDYES){system("cls"); }else{return 0;} }	}
}
}

制作不易,希望大家三连,谢谢。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/450725.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

高考志愿填报模拟系统的功能和技术总结

一、金秋志愿高考志愿填报系统主要功能&#xff1a; 用户注册与登录&#xff1a;允许学生和家长注册账号&#xff0c;使用注册的账号登录系统。 个人信息管理&#xff1a;允许用户查看、修改个人信息&#xff0c;如姓名、性别、联系方式等。 高考成绩输入&#xff1a;学生输…

【安装指南】maven下载、安装与配置详细教程

&#x1f33c;一、概述 maven功能与python的pip类似。 Apache Maven是一个用于软件项目管理和构建的强大工具。它是基于项目对象模型的&#xff0c;用于描述项目的构建配置和依赖关系。以下是一些关键的 Maven 特性和概念&#xff1a; POM&#xff08;Project Object Model&…

探索前端开发框架:React、Angular 和 Vue 的对决(一)

&#x1f90d; 前端开发工程师、技术日更博主、已过CET6 &#x1f368; 阿珊和她的猫_CSDN博客专家、23年度博客之星前端领域TOP1 &#x1f560; 牛客高级专题作者、打造专栏《前端面试必备》 、《2024面试高频手撕题》 &#x1f35a; 蓝桥云课签约作者、上架课程《Vue.js 和 E…

爬取58二手房并用SVR模型拟合

目录 一、前言 二、爬虫与数据处理 三、模型 一、前言 爬取数据仅用于练习和学习。本文运用二手房规格sepc(如3室2厅1卫)和二手房面积area预测二手房价格price&#xff0c;只是练习和学习&#xff0c;不代表如何实际意义。 二、爬虫与数据处理 import requests import cha…

[office] 在Excel2010中设定某些单元格数据不参与排序的方法介绍 #其他#知识分享#笔记

在Excel2010中设定某些单元格数据不参与排序的方法介绍 在Excel中排序&#xff0c;相信大家都会了&#xff0c;直接将一组数据按照从小到大或者从大到小进行排序&#xff0c;但是&#xff0c;现在要求我们规定其中几组数据不进行排序&#xff0c;只排序其余的部分。又该如何操作…

批量检测微信小程序是否封禁接口源码

<?php // 要检测的 appid 列表 $appids array(appid1, appid2, appid3); // 使用实际的 appid // 循环调用接口检测小程序状态 foreach ($appids as $appid) { $url https://yan.changxunwangluo.cn/xcx/check_mini_program.php?appid . urlencode($appid); $…

TOP100 链表(三)

7.2. 两数相加 给你两个 非空 的链表&#xff0c;表示两个非负的整数。它们每位数字都是按照 逆序 的方式存储的&#xff0c;并且每个节点只能存储 一位 数字。 请你将两个数相加&#xff0c;并以相同形式返回一个表示和的链表。 你可以假设除了数字 0 之外&#xff0c;这两…

代码随想录day17--二叉树的应用5

LeetCode654.最大二叉树 题目描述&#xff1a; 给定一个不重复的整数数组 nums 。 最大二叉树 可以用下面的算法从 nums 递归地构建: 创建一个根节点&#xff0c;其值为 nums 中的最大值。递归地在最大值 左边 的 子数组前缀上 构建左子树。递归地在最大值 右边 的 子数组后…

再谈Redis三种集群模式:主从模式、哨兵模式和Cluster模式

总结经验 redis主从:可实现高并发(读),典型部署方案:一主二从 redis哨兵:可实现高可用,典型部署方案:一主二从三哨兵 redis集群:可同时支持高可用(读与写)、高并发,典型部署方案:三主三从 一、概述 Redis 支持三种集群模式,分别为主从模式、哨兵模式和Cluster模式。…

第六十一天 服务攻防-中间件安全CVE复现K8SDockerJettyWebsphere

第61天 服务攻防-中间件安全&CVE复现&K8S&Docker&Jetty&Websphere 知识点&#xff1a; 中间件及框架列表&#xff1a; lIS,Apache,Nginx,Tomcat,Docker,Weblogic,JBoos,WebSphere,Jenkins, GlassFish,Jira,Struts2,Laravel,Solr,Shiro,Thinkphp,Sprng,Fl…

视频上传-分片上传那点事

在上一篇文章中&#xff0c;我们讲解了从视频上传到保存在服务端的整个过程&#xff0c;在这个过程中&#xff0c;我们又细分了前端上传视频的几种方式&#xff0c;前端处理视频的几种方式&#xff0c;在前后端通信过程中需要注意的哪些点等等。有不清楚的小伙伴可以看看 上篇文…

Spring IoC容器(二)Bean的自定义及容器的扩展

Spring提供了一些接口来让我们定制bean 及扩展容器。 1 定制Bean 我们可以通过bean及容器的生命周期回调及一些Aware接口来定制bean。 1.1 生命周期回调 1.1.1 InitializingBean 与 DisposableBean 我们可以通过让Bean 实现InitializingBean 及DisposableBean 接口&#x…