游戲終端伺服器分享(1.2版)

来源:https://www.cnblogs.com/eason66-blog/archive/2020/02/11/GC-server.html
-Advertisement-
Play Games

(使用前請將其命名為GC_servy.cpp,否則可能會出錯) #include<stdlib.h> #include<stdio.h> #include<time.h> //suiji #include<string.h> #include<windows.h> //SLEEP函數 #includ ...


(使用前請將其命名為GC_servy.cpp,否則可能會出錯)

#include<stdlib.h>
#include<stdio.h>
#include<time.h> //suiji
#include<string.h>
#include<windows.h> //SLEEP函數
#include<iostream>
#include<algorithm>
#include<conio.h>
#include<pthread.h>
#include<fstream>
#include <queue>
#include <math.h>
#define Height 25 //迷宮的高度,必須為奇數
#define Width 25 //迷宮的寬度,必須為奇數
#define Wall 1
#define Road 0
#define Start 2
#define End 3
#define Esc 5
#define Up 1
#define Down 2
#define Left 3
#define Right 4
using namespace std;
#define next 32
string UsersName;
int getint4(int *index=NULL){
	char c;
	int a;
	while((c=getch())!=13){
		cout << c-'0';
		a*=10;
		a+=c-'0';
	}
	cout << "\n";
	return a;
}
#define getint getint4
int getint3(){
	int a;
	a=getch()-'0';
	return a;
}//用按鍵讀入數字(0~9) 
void print(string a,int speed=100){
	for(int i=0;i<a.length();i++){
		printf("%c",a[i]);
		Sleep(speed);
	}
}
struct monster{
	string name,thing;
	int gongji,fangyu,hp,gold_ko,gold_koi,thing_number;
}
strongman={"森林巨人","",350,350,500,100,1500,0},big_strongman={"巨人之王","巨人之臂",350*5,350*5,500*5,100*5,1500*5,1},xiyi={"森林蜥蜴","鐵甲",100,100,200,30,500,2},whitch={"森林女巫","防彈衣",180,180,350,50,1000,3},bee={"草原黃蜂","劍",100,100,200,30,500,4},horse={"草原野馬","碧血劍",180,180,350,50,1000,5},lion={"草原雄獅","絕世好劍",350,350,500,100,1500,6},shitu={"使徒","",350*7,350*7,500*7,0,0,0},guai;
struct player{
	string name;
	int hp,gongji,fangyu,gold,thing_fang,thing_gong,max_hp,level,exp,max_exp;
}
play={"",100,50,40,500,0,0,100,1,0,100};
bool frees=false;
int plase=0;
int grass=3,bag=2,medicine=2,super_medicine=1,boom=3,dead=2,hoom=1;
int clothes,tie,fang,gold_clothes,arm,very_small,small,big,good;
bool vs_now;
int number;
void choose_things(){
	char data[100];
	sprintf(data,"===================\n1.止血草%d個   2.急救包%d個    3.雲南白藥%d個   4.超級雲南白藥%d個     5.手雷%d個   6.毒標%d個    7.手拋式原子彈%d個    0.退出\n",grass,bag,medicine,super_medicine,boom,dead,hoom);
	printf(data);
	number=getint();
	switch(number){
		case 1:if(grass==0){
			print("沒有止血草了\n");
			break;
		}
		if(play.hp+50>play.max_hp){
			print("hp過多,不需要止血草\n");
			break;
		}
		play.hp+=50;
		grass--;
		break;
		case 2:if(bag==0){
			print("沒有急救包了\n");
			break;
		}
		if(play.hp+80>play.max_hp){
			print("hp過多,不需要急救包\n");
			break;
		}
		play.hp+=80;
		bag--;
		break;
		case 3:if(medicine==0){
			print("沒有雲南白藥了\n");
			break;
		}
		if(play.hp+100>play.max_hp){
			print("hp過多,不需要雲南白藥\n");
			break;
		}
		play.hp+=100;
		medicine--;
		break;
		case 4:if(super_medicine==0){
			print("沒有超級雲南白藥了\n");
			break;
		}
		if(play.hp+200>play.max_hp){
			print("hp過多,不需要超級雲南白藥了\n");
			break;
		}
		play.hp+=200;
		super_medicine--;
		break;
		case 5:if(!vs_now){
			print("非戰鬥狀態,不能使用手雷\n");
			break;
		}
		if(boom==0){
			print("沒有手雷了\n");
			break;
		}
		print("使用手雷,敵人hp減少100");
		guai.hp-=100;
		boom--;
		print("\n\n");
		cout << guai.name;
		print("反擊!!你的hp減少");
		cout << guai.gongji/3-play.fangyu;
		play.hp-=guai.gongji/3-play.fangyu;
		cout << "\n";
		break;
		case 6:if(!vs_now){
			print("非戰鬥狀態,不能使用毒標\n");
			break;
		}if(dead==0){
			print("沒有毒標了\n");
			break;
		}
		print("使用毒標,敵人hp減少200\n\n");
		guai.hp-=200;
		cout << guai.name;
		dead--;
		print("反擊!!你的hp減少");
		cout << guai.gongji/3-play.fangyu;
		play.hp-=guai.gongji/3-play.fangyu;
		cout << "\n";
		break;
		case 7:if(!vs_now){
			print("非戰鬥狀態,不能使用手拋式原子彈\n");
			break;
		}
		if(hoom==0){
			print("沒有手拋式原子彈了\n");
			break;
		}
		hoom--;
		print("使用手拋式原子彈,敵人hp減少500\n\n");
		char data[100];
		guai.hp-=500;
		cout << guai.name;
		sprintf(data,"反擊!!你的hp減少了%d",guai.gongji/3-play.fangyu);
		play.hp-=guai.gongji/3-play.fangyu;
		printf(data);
	}
}
void check(){
	char data[200];
	sprintf(data,"\n\n\n\n====================\n攻擊力%d+%d   防禦力%d+%d     hp:%d/%d\n\n等級%d   還需要%d經驗升級    金幣%d\n",play.gongji,play.thing_gong,play.fangyu,play.thing_fang,play.hp,play.max_hp,play.level,play.max_exp-play.exp,play.gold);
	printf(data);
}
void vs(){
	srand(rand());
	vs_now=true;
	while(play.hp>0&&guai.hp>0){
		print("\n\n\n\n\n\n\n=====================================\n\n\n要怎麼辦?\n1.攻擊   2.物品    3.查看狀態   4.逃跑\n",0);
		number=getint();
		switch(number){
			case 1:cout << play.name;
			print("攻擊!!敵人hp減少");
			cout << play.gongji+play.thing_gong-guai.fangyu/3;
			guai.hp-=play.gongji+play.thing_gong-guai.fangyu/3;
			print("\n\n");
			cout << guai.name;
			print("反擊!你的hp減少");
			cout << guai.gongji/3-play.fangyu-play.thing_fang;
			play.hp-=guai.gongji/3-play.fangyu-play.thing_fang;
			cout << "\n";
			break;
			case 2:choose_things();break;
			case 3:check();break;
			case 4:int s=rand()%10;
			srand(rand());
			if(s<4){
				print(play.name);
				print("逃跑了~\n");
				return ;
			}
			else{
				print(play.name);
				print("逃跑失敗!\n");
			}
			break;
		}
		print("\n\n\n\n\n");
	}
	if(play.hp==0){
		print(play.name);
		print("戰死!!金幣掉落");
		cout << guai.gold_koi;
		play.gold-=guai.gold_koi;
		if(play.gold<0){
			play.gold=0;
		}
		play.hp=play.max_hp;
	}
	else{
		if(guai.name=="使徒"){
			print("戰鬥勝利,救出公主!!");
			frees=true;
			return ;
		}
		else{
			print("戰鬥勝利!!!獲得經驗100,金幣");
			cout << guai.gold_ko;
			play.exp+=100;
			play.gold+=guai.gold_ko;
			int s=rand()%10;
			print("\n\n\n");
			if(s<4){
				print("從敵人屍體中發現");
				cout << guai.thing;
				switch(guai.thing_number){
					case 0:gold_clothes++;break;
					case 1:arm++;break;
					case 2:tie++;break;
					case 3:fang++;break;
					case 4:small++;break;
					case 5:big++;break;
					case 6:good++;break;
				}
				print("\n\n\n\n");
			}
			while(play.exp>=play.max_exp){
				print(play.name);
				print("升級!!攻擊力+3,防禦力+2,hp上限+100\n");
				play.gongji+=3;
				play.fangyu+=2;
				play.max_hp+=100;
				play.exp-=play.max_exp;
				play.max_exp+=100;
				print("\n\n");
			}
			play.hp=play.max_hp;
		}
	}
}
int zbg(int number,int power,string name){
	if(number==0){
		print("沒有");
		print(name);
		print("了\n");
		return 0;
	}
	print("拿起了");
	print(name);
	play.thing_gong=power;
	return 0;

}
int zbf(int number,int power,string name){
	if(number==0){
		print("沒有");
		print(name);
		print("了\n");
		return 0;
	}
	print("穿上了");
	print(name);
	play.thing_fang=power;
	return 0;

}
int drink(int x){
	if(play.gold<x){
		print("錢不夠!!!\n");
		return 0;
	}
	if(play.hp+x>play.max_hp){
		print("hp太多,不用喝酒\n");
		return 0;
	}
	play.hp+=x;
	play.gold-=x;
	return 0;
}
int cs(){
	srand(time(0));
	int bar=rand(),hotel=rand(),forest_1=rand(),forest_2=rand(),forest_3=rand(),grass_1=rand(),grass_2=rand(),grass_3=rand();
	print("這是一個勇者的世界!!雅麗薩斯國的羅茜公主被陌生人綁架了!!\n\n\n偉大的勇者啊,拿起武器,營救公主!!!\n\n\n");
	play.name=UsersName;
	if(play.name=="EVA初號機"){
		print("封印多年的EVA初號機啊,你終於可以重見天日了!!!\n\n\nEVA初號機,重新啟動...隨即,暴走!!!\n");
		play.fangyu+=10000;
		play.gongji+=10000;
		play.max_hp+=10000;
		play.hp+=10000;
	}
	if(play.name=="seven"||play.name=="eason"||play.name=="carolyn"){
		print("曾救出公主的勇士啊,你終於回來了!!!隨即,暴走!!!!!\n");
		play.fangyu+=10000;
		play.gongji+=10000;
		play.max_hp+=10000;
		play.hp+=10000;
	}
	bool say=false;
	while(!frees){
		print("\n\n\n\n===========================================\n\n\n\n\n要做什麼?\n1.移動  2.物品   3.對話   4.查看狀態  5.裝備  0.退出\n",0);
		number=getint();
		switch(number){
			case 1:print("\n\n\n\n\n\n================================================\n\n\n要去哪裡?\n1.酒吧   2.旅店    3.森林一層   4.森林二層   5.森林三層   6.草原一層   7.草原二層   8.草原三層\n",0);
			number=getint();
			switch(number){
				case 1:plase=bar;break;
				case 2:plase=hotel;
				print("要住店嗎?200個金幣,可以讓你hp變滿哦\n1.是  0.否");
				number=getint();
				if(number){
					if(play.gold<200){
						print("金幣不夠!!!");
						break;
					}
					play.gold-=200;
					print("第二天了\n\thp滿了\n\t\t下次再來!");
					int s=rand()%10;
					if(s<4){
						print("臨走時發現其他客人遺留的");
						s=rand()%8+1;
						if(s<=3){
							print("止血草");
							grass++;
						}else if(s<=5){
							print("急救包");
							bag++;
						}
						else if(s<=7){
							print("雲南白藥");
							medicine++;
						}
						else{
							print("超級雲南白藥");
							super_medicine++;
						}
						print("一個和");
						s=rand()%6+1;
						if(s<=3){
							print("手雷");
							boom++;
						}else if(s<=5){
							print("毒標");
							dead++;
						}
						else{
							print("手拋式原子彈");
							hoom++;
						}
						print("一個\n");
					}
					play.hp=play.max_hp;
					break;
				}
				else{
					print("下次再來!\n");
					break;
				}
				case 3:plase=forest_1;
				int s;
				s=rand()%10;
				if(s<7){
					guai=xiyi;
					print("森林蜥蜴撲了過來!\n");
					vs();
				}
				else if(s<9){
					guai=whitch;
					print("森林女巫撲了過來!!\n");
					vs();
				}
				else{
					print("這裡安全\n");
				}
				break;
				case 4:plase=forest_2;
				s=rand()%10;
				if(s<7){
					guai=whitch;
					print("森林女巫撲了過來!!\n");
					vs();
				}
				else if(s<9){
					guai=strongman;
					print("森林巨人撲了過來!!!\n");
					s=rand()%10;
					if(s<8){
						guai.thing="黃金聖衣";
						guai.thing_number=0;
					}
					else{
						guai.thing="巨人之臂";
						guai.thing_number=1;
					}
					vs();
				}
				else{
					print("這裡安全\n");
				}
				break;
				case 5:plase=forest_3;
				s=rand()%10;
				if(s<7){
					guai=strongman;
					print("森林巨人撲了過來!!!\n");
					s=rand()%10;
					if(s<8){
						guai.thing="黃金聖衣";
						guai.thing_number=0;
					}
					else{
						guai.thing="巨人之臂";
						guai.thing_number=1;
					}
					vs();
				}
				else if(s<9){
					guai=big_strongman;
					print(guai.name);
					print("撲了過來!!!!\n");
					vs();
				}
				else{
					print("這裡安全\n");
				}
				break;
				case 6:plase=grass_1;
				s=rand()%10;
				if(s<7){
					guai=bee;
					print("草原黃蜂撲了過來!\n");
					vs();
				}else if(s<9){
					guai=horse;
					print("草原野馬撲了過來!!\n");
					vs();
				}
				else{
					print("這裡安全\n");
				}
				break;
				case 7:plase=grass_2;
				s=rand()%10;
				if(s<7){
					guai=horse;
					print("草原野馬撲了過來!!\n");
					vs();
				}else if(s<9){
					guai=lion;
					print("草原雄獅撲了過來!!!\n");
					vs();
				}
				else{
					print("這裡安全\n");
					vs();
				}
				break;
				case 8:plase=grass_3;
				s=rand()%10;
				if(s<7){
					guai=lion;
					print("草原雄獅撲了過來!!!\n");
					vs();
				}else if(s<9){
					if(arm==0){
						if(say){
							print("神秘老人:加油吧,年輕人,爭取獲得巨人之臂!^_^\n");
						}
						else{
							print("神秘老人:如果你有巨人之臂,我就告訴你公主的下落哦!^_^\n");
						}
					}
					else{
						print("神秘老人:年輕人,做的不錯。不過……嘿嘿,你上當了。巨人之臂我要了,公主你也別想帶走!!!\n\n\n");
						guai=shitu;
						print("使徒撲了過來!!!!\n");
						vs();
					}
				}
				else{
					print("這裡安全\n");
				}
			}
			break;
			case 2:choose_things();break;
			case 3:if(plase==bar){
				print("要和誰說話?\n1.紅髮女郎    2.賞金獵人    3.酒吧老闆\n");
				cin >> number;
				switch(number){
					case 1:print("紅髮女郎:吧台那邊的獵人好帥啊!!^_^\n");break;
					case 2:if(clothes==0){
						print("賞金獵人:你要救公主啊,好膽量!不過外面的草原和叢林很險惡,而且越深越危險。這是匕首和布衣,對你會有幫助的。\n\n");
						print(play.name);
						print("心想:這位大叔人真好啊!\n");
						clothes++;
						very_small++;
						break;
					}
					else{
						print("賞金獵人:加油吧,年輕人,不要被外面的叢林和草原所嚇倒!^_^");
						break;
					}
					case 3:print("酒吧老闆:要喝點什麼?1.二鍋頭25金幣,hp+25    2.xo酒50金幣,hp+50      3.人頭馬面100金幣,hp+100    4.青花郎200金幣,hp+200     5.茅臺酒500金幣,hp+500\n");
					number=getint();
					switch(number){
						case 1:drink(25);break;
						case 2:drink(50);break;
						case 3:drink(100);break;
						case 4:drink(200);break;
						case 5:drink(500);break;
					}
					break;
				}
				break;
			}
			else{
				print("這裡好像沒人可以聊天");
				break;
			}
			break;
			case 4:check();break;
			case 5:print("選擇要更換的裝備:\n\n");
			#undef data
			char data[100];
			sprintf(data,"1.匕首%d個    2.劍%d個     3.碧血劍%d個     4.絕世好劍%d個      \n5.布衣%d個     6.鐵甲%d個     7.防彈衣%d個         8.黃金聖衣%d個\n",very_small,small,big,good,clothes,tie,fang,gold_clothes);
			printf(data);
			number=getint();
			switch(number){
				case 1: zbg(very_small,30,"匕首");break;
				case 2: zbg(small,50,"劍");break;
				case 3: zbg(big,100,"碧血劍");break;
				case 4: zbg(good,200,"絕世好劍");break;
				case 5: zbf(clothes,30,"布衣");break;
				case 6: zbf(tie,50,"鐵甲");break;
				case 7: zbf(fang,100,"防彈衣");break;
				case 8: zbf(gold_clothes,200,"黃金聖衣");break;
			}
			break;
			case 0: print("確定退出游戲?\n1.是    0.否");
			number=getint();
			if(number){
				return 0;
			}
			break;
		}
	}
	system("pause");
	return 0;
}
int ctjdb()
{
    int a,b,s=0,t;
    cout<<"請選擇電腦的速度,一個整數,越大越慢。";
    t=getint();
    for(;;)
    {
        cout<<"請選擇出什麼:\n1.石頭\n2.剪刀\n3.布\n4.不玩了\n";
        for(int i=1;i<=t;i++)
          b=rand()%3;
        b+=1;
        a=getint();
        if(a==4)
          break;
        if(b==1)
          cout<<"電腦出石頭,";
        if(b==2)
          cout<<"電腦出剪刀,";
        if(b==3)
          cout<<"電腦出布,";
        if(a+1==b||a-2==b)
          cout<<"你贏了!!\n";
        if(a-1==b||a+2==b)
          cout<<"你輸了!!\n";
        if(a==b)
          cout<<"平局。。\n";
        s++;
    }
    cout<<"下次再來喲~~";
    return 0;
}
int n,m;
bool c[100005];
int cq3_1()
{
    cout<<"猜數 3.1\n";
    srand(time(NULL));
    cout<<"==============================================================\n幾人猜數(只支持100000人以內)??\n";
    n=getint();
    cout<<"==============================================================\n0~幾??\n";
    m=getint();
    for(;;)
    {
        cout<<"==============================================================\n開始!!!\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)\n",y=getint();
            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");
    }
    return 0;
}
int cq3_2()
{
    cout<<"猜數 3.2\n"; 
    srand(time(NULL));
    cout<<"==============================================================\n幾人猜數(只支持100000人以內)??";
    getint(&n);
    cout<<"==============================================================\n0~幾??";
    m=getint();
    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)",y=getint();
            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");
    }
    return 0; 
}

int f[111][111];
int i,d[10],a,j,ett=0,headx[10],t1,d8=1,dev_c,heady[10],k=7,rm[10],d2[10],k1,l,t=250,i3;
int fdx[1111],fdy[1111],v=10,hd[10],tl[10],djx,djy,typ,dj[111],x4[10][10000],y4[10][10000],i1,vt;
pthread_t tid,sna,tim;
double sc,hsc;
FILE* f3;
char ch;
/******************************
*0 up ;1 down ;2 left; 3 right*
*i是迴圈變數 t是sleep時間,n是*
*長,m是寬,k1,x4和y4是方向臨時變數  *
*f是地圖,fdx和fdy是食物位置  *
*hd頭,tl尾  是隊列, *
*i1是迴圈變數,sc是分數,tid是*
*線程 f3是文件指針,ch是y/n。 *
******************************/
void co1()
{
    COORD c;
    c.X=0;
    c.Y=0;
    SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),c);
}
void co(int color1)
{
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),color1);
}
void* f1(void* args)//另一個線程,負責拐彎
{
    for(;;)
    {
        if(ett==1)//線程結束哨兵
        return 0;
        a=getch();
        if(a==224)
        {
            a=getch();  //上下左右方向鍵
            if(a==72&&d2[7]!=1)//防止掉頭
            d[7]=0;
            if(a==80&&d2[7]!=0)
            d[7]=1;
            if(a==75&&d2[7]!=3)
            d[7]=2;
            if(a==77&&d2[7]!=2)
            d[7]=3;
        }
        else
        {
            if(a==119&&d2[6]!=1)   //WASD
            d[6]=0;
            if(a==115&&d2[6]!=0)
            d[6]=1;
            if(a==97&&d2[6]!=3)
            d[6]=2;
            if(a==100&&d2[6]!=2)
            d[6]=3;
        }
    }
}
void* f2(void* args)
{
    for(;;)
    {
        Sleep(1000);
        d8++;
    }
}
void print()
{
    printf("score=%.2lf\n",sc);
    printf(" ");
    for(i=0;i<m*2;i++)
    printf("-");//邊框
    printf("\n");
    for(i=1;i<=n;i++)
    {
        printf("|");
        for(j=1;j<=m;j++)
        {
            if(f[j][i]==0)
            printf(" ");//空間
            else if(f[j][i]==8)
            printf("◆");//食物
            else if(f[j][i]>=257)
            printf("□");
            else
            {
                co(f[j][i]+8);
                for(i1=1;i1<=7;i1++)
                {
                    if(j==x4[i1][hd[i1]]&&i==y4[i1][hd[i1]])
                    {
                        co(f[j][i]+4);
                    }
                }
                printf("█");//蛇身
                co(7);
            }
        }
        printf("|");
        printf("\n");
    }
    printf(" ");
    for(i=0;i<m*2;i++)
    printf("-");
    printf("\n");
    printf("\nscore=%.2lf\n\nhighest score is%.2lf\n",sc,hsc);
}
int check(int b1)
{
    int er=1;
    for(i=1;i<=v;i++)
        {
            if(x4[b1][hd[b1]]==fdx[i]&&y4[b1][hd[b1]]==fdy[i])
            {
                sc+=sqrt((hd[b1]-tl[b1])*1.0/v/sqrt(m*n*d8))*40;
                i3=0;
                do
                {
                    i3++;
                    fdx[i]=rand()%m+1;//隨機生成食物
                    fdy[i]=rand()%n+1;
                }while(f[fdx[i]][fdy[i]]!=0&&i3<10000);
                f[fdx[i]][fdy[i]]=8;
                if(i3>9998)
                {
                    er=2;
                    goto re;
                }
                if(rand()%3==0&&djx==0&&djy==0)
                {
                    do
                    {
                        djx=rand()%m+1;
                        djy=rand()%n+1;         //生成道具
                    }while(f[djx][djy]!=0);
                    typ=1;
                    f[djx][djy]=typ+256;
                }
                er=0;
            }
        }
        if(x4[b1][hd[b1]]==djx&&y4[b1][hd[b1]]==djy)
        {
            f[djx][djy]=b1;
            djx=0;
            djy=0;
            if(rand()%7==0)
            sc*=1.5;
            else if(rand()%6==1)
            sc/=1.5;
            else if(rand()%5==2)
            {
                t*=1.5;
                sc*=0.9;
            }
            else if(rand()%4==3)
            {
                t/=1.5;
                sc*=1.1;
            }
            else
            {
                rm[b1]=rand()%3+2;
                sc=sc+rand()%10-4;
            }
        }
    re:return er;
}
void do1(int b1)
{
    int d1=d[b1];
        hd[b1]++;
        x4[b1][hd[b1]]=x4[b1][hd[b1]-1];
        y4[b1][hd[b1]]=y4[b1][hd[b1]-1];
        if(d1==0)
        {
            y4[b1][hd[b1]]--;
        }
        if(d1==1)
        {
            y4[b1][hd[b1]]++;
        }
        if(d1==2)
        {
            x4[b1][hd[b1]]--;//移動
        }
        if(d1==3)
        {
            x4[b1][hd[b1]]++;
        }
        if(x4[b1][hd[b1]]<1)
        x4[b1][hd[b1]]=m;
        else if(y4[b1][hd[b1]]<1)
        y4[b1][hd[b1]]=n;
        else if(x4[b1][hd[b1]]>m)//穿牆
        x4[b1][hd[b1]]=1;
        else if(y4[b1][hd[b1]]>n)
        y4[b1][hd[b1]]=1;
        if(!vt)
        i3=check(b1);
        if(i3==2)
        {
            vt=1;//停止檢測
            sc+=(rand()%10)/10.0;
        }
        else if(i3==1)//檢測是否吃到東西
        {
            f[x4[b1][tl[b1]]][y4[b1][tl[b1]]]=0;//尾動
            tl[b1]++;
        }
        for(i=tl[b1];i<hd[b1]-1;i++)
        if((x4[b1][hd[b1]]==x4[b1][i]&&y4[b1][hd[b1]]==y4[b1][i]))
        {
            f3=fopen("snake.ini","w");
            hsc=hsc>sc?hsc:sc;
            fprintf(f3,"%lf\n",hsc);
            fprintf(f3,"%d %d %d %d %d\n",n,m,v,t1,k1);
            fclose(f3);
            f3=fopen("snake.log","a");
            fprintf(f3,"%lf\n",sc);
            fprintf(f3,"%d %d %d %d %d\n\n",n,m,v,t1,k1);
            fclose(f3);
            if(MessageBoxA(NULL,TEXT("想在玩一局嗎"),TEXT("snake"),MB_YESNO|MB_SYSTEMMODAL)==IDYES)//彈出在玩一局
            {
                ett=1;//結束線程
                Sleep(1);
                system("snake");//不要臉的重新開始
            }
            exit(0);
        }
        f[x4[b1][hd[b1]]][y4[b1][hd[b1]]]=b1;//頭動
    return;
}
void init()
{
    system("mode con cols=180 lines=180");
    system("title SnakeBata0.6.3");
    printf("自定義(Y)/預設(N)/上一次(L)?Y/N/L\n");
    ch=getch();
    f3=fopen("snake.ini","a");
    fclose(f3);
    f3=fopen("snake.ini","r");
    fscanf(f3,"%lf",&hsc);
    if(ch=='L'||ch=='l')
    fscanf(f3,"%d %d %d %d %d",&n,&m,&v,&t,&k1);
    fclose(f3);
    if(ch=='y'||ch=='Y')
    {
        printf("輸入行數 列數 食物數 速度 蛇數\n(一個一個輸,輸完了一個後別忘了換行哦親~)");
        //scanf("%d %d %d %d %d",&n,&m,&v,&t,&k1);
        n=getint4();
        getint4(&m);
        getint4(&v);
        t=getint();
        k1=getint4();
        k=8-k1;
        if(k<0)
        k=1;
    }
    f3=fopen("snake.ini","w");
    fprintf(f3,"%lf\n",hsc);
    fprintf(f3,"%d %d %d %d %d",n,m,v,t,k1);
    fclose(f3);
    t1=t;
    srand(time(NULL));
    pthread_create (&tid,NULL,f1,NULL);
    pthread_create (&tim,NULL,f2,NULL);
    for(i=7;i>=k;i--)
    {
        hd[i]=1;
        tl[i]=1;
        x4[i][1]=rand()%m+1;//隨機生成蛇的初始位置
        y4[i][1]=rand()%n+1;
        f[x4[i][1]][y4[i][1]]=i;
    }
    for(i=1;i<=v;i++)
    {
        do
        {
            fdx[i]=rand()%m+1;//隨機生成食物
            fdy[i]=rand()%n+1;
        }while(f[fdx[i]][fdy[i]]!=0);
        f[fdx[i]][fdy[i]]=8;
    }
}
int tcs()
{
	n=m=15;
    init();
    system("cls");
    for(;;)//主迴圈
    {
        d2[6]=d[6];
        d2[7]=d[7];
        Sleep(t);
        for(i1=7;i1>=k;i1--)
        {
            if(rm[i1]==0)
            do1(i1);
            else
            {
                if(hd[i1]-tl[i1]>5)
                {
                    f[x4[i1][tl[i1]]][y4[i1][tl[i1]]]=0;
                    tl[i1]++;
                    rm[i1]--;
                }
                else
                {
                    rm[i1]=0;
                    do1(i1);
                }
            }
            for(i=tl[i1];i<=hd[i1];i++)
            f[x4[i1][tl[i1]]][y4[i1][tl[i1]]]=i1;
        }
        if(t>t1)
        t--;
        else if(t<t1)
        t++;
        co1();
        //system("cls");
        print();
    }
	free(&a);
}
int map[Height+2][Width+2];
void gotoxy(int x,int y) //移動坐標
{
COORD coord;
coord.X=x;
coord.Y=y;
SetConsoleCursorPosition( GetStdHandle( STD_OUTPUT_HANDLE ), coord );
}
void hidden()//隱藏游標
{
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_CURSOR_INFO cci;
GetConsoleCursorInfo(hOut,&cci);
cci.bVisible=0;//賦1為顯示,賦0為隱藏
SetConsoleCursorInfo(hOut,&cci);
}
void create(int x,int y) //隨機生成迷
{
int c[4][2]={0,1,1,0,0,-1,-1,0}; //四個方向
int i,j,t;
//將方向打亂
for(i=0;i<4;i++)
{
j=rand()%4;
t=c[i][0];c[i][0]=c[j][0];c[j][0]=t;
t=c[i][1];c[i][1]=c[j][1];c[j][1]=t;
}
map[x][y]=Road;
for(i=0;i<4;i++)
if(map[x+2*c[i][0]][y+2*c[i][1]]==Wall)
{
map[x+c[i][0]][y+c[i][1]]=Road;
create(x+2*c[i][0],y+2*c[i][1]);
}
}
int get_key() //接收按鍵
{
char c;
while(c=getch())
{
if(c==27) return Esc; //Esc
if(c!=-32)continue;
c=getch();
if(c==72) return Up; //上
if(c==80) return Down; //下
if(c==75) return Left; //左
if(c==77) return Right; //右
}
return 0;
}
void paint(int x,int y) //畫迷宮
{
gotoxy(2*y-2,x-1);
switch(map[x][y])
{
case Start:
printf("入");break; //畫入口
case End:
printf("出");break; //畫出口
case Wall:
printf("▇");break; //畫牆
case Road:
printf(" ");break; //畫路
}
}
char aa;
void game()
{
int x=2,y=1; //玩家當前位置,剛開始在入口處
int c; //用來接收按鍵
while(1)
{
gotoxy(2*y-2,x-1);
printf("●"); //畫出玩家當前位置
if(map[x][y]==End) //判斷是否到達出口
{
gotoxy(30,24);
printf("到達終點,按任意鍵結束\n");
break;
}
c=get_key();
if(c==Esc)
{
gotoxy(0,24);
break;
}
switch(c)
{
case Up: //向上走
if(map[x-1][y]!=Wall)
{
paint(x,y);
x--;
}
break;
case Down: //向下走
if(map[x+1][y]!=Wall)
{
paint(x,y);
x++;
}
break;
case Left: //向左走
if(map[x][y-1]!=Wall)
{
paint(x,y);
y--;
}
break;
case Right: //向右走
if(map[x][y+1]!=Wall)
{
paint(x,y);
y++;
}
break;
}
}
}
int mg()
{
	system("title MgBata0.6.3");
int i,j;
srand((unsigned)time(NULL)); //初始化隨即種子
hidden(); //隱藏游標
for(i=0;i<=Height+1;i++)
for(j=0;j<=Width+1;j++)
if(i==0||i==Height+1||j==0||j==Width+1) //初始化迷宮
map[i][j]=Road;
else map[i][j]=Wall;
create(2*(rand()%(Height/2)+1),2*(rand()%(Width/2)+1)); //從隨機一個點開始生成迷宮,該點行列都為偶數
for(i=0;i<=Height+1;i++) //邊界處理
{
map[i][0]=Wall;
map[i][Width+1]=Wall;
}
for(j=0;j<=Width+1;j++) //邊界處理
{
map[0][j]=Wall;
map[Height+1][j]=Wall;
}
map[2][1]=Start; //給定入口
map[Height-1][Width]=End; //給定出口
for(i=1;i<=Height;i++)
for(j=1;j<=Width;j++) //畫出迷宮
paint(i,j);
game(); //開始游戲
return 0;
}
#define n2 20
using namespace std;

//函數定義
void sch(int color);
void fileout();
void print(const char a[],int b);
void Initialize();
void gotoxy(int x,int y);
void cursor(bool a);
void shop(int c);
void warout(int xx,int yy);
void war(int c);
void game();
bool issame(string x);
bool charsame(char a[105],char b[105],int blen);
int canfind(int len);
bool login_register();
void enter();

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//存檔系統
struct users{
    char name[105];int namelen;
    char password[105];int passwordlen;
    int gold,h,u;
}user[100005];
int usertot,nowuser;
void fileout(){
    freopen("game.txt","w",stdout);
    cout<<usertot<<endl;
    for (int i=1;i<=usertot;i++)cout<<user[i].name<<' '<<user[i].namelen<<' '<<user[i].password<<' '<<user[i].passwordlen<<' '<<user[i].gold<<' '<<user[i].h<<' '<<user[i].u<<endl;
    exit(0);
}
//存檔系統
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//工具程式
void sch(int color){
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), color);
    return;
}
void print(const char a[],int b){
    int s=strlen(a);
    for(int i=0;i<s;i++){
        printf("%c",a[i]);
        Sleep(b);
    }
}
void Initialize(){
    system("color f0");
    RECT rect;
    HWND hwnd=GetForegroundWindow();
    GetWindowRect(hwnd,&rect);
    MoveWindow(hwnd,0,0,rect.right-rect.left,rect.bottom-rect.top,TRUE);
    system("mode con cols=90 lines=30");
}
void gotoxy2(int x,int y){
    COORD pos;
    pos.X=2*x;
    pos.Y=y;
    SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos);
}
void cursor(bool a){
    HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
    CONSOLE_CURSOR_INFO CursorInfo;
    GetConsoleCursorInfo(handle, &CursorInfo);
    CursorInfo.bVisible = a;
    SetConsoleCursorInfo(handle, &CursorInfo);
}
//工具程式
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//神之商城
void shop(int c){
    system("cls");
    cout<<"剩餘金幣:"<<user[c].gold<<endl;
    cout<<"按H購買武器"<<endl;
    cout<<"按U購買技能"<<endl;
    char x;
    x=getch();
    if(x>='a'){
    	x-='a'-'A';
	}
    if (x!='H'&&x!='U'){cout<<"操作失敗!"<<endl;Sleep(500);return;}
    if (x=='H'){
        cout<<endl<<"請輸入武器編號購買武器"<<endl;
        cout<<"1 神之劍 花費0金幣"<<endl;
        cout<<"2 激光槍 花費200金幣" <<endl;
        cout<<"3 激光炮 花費400金幣"<<endl;
        cout<<"4 概率槍 花費1500金幣"<<endl;
        cout<<"5 電之弓 花費1000金幣"<<endl;
        int cost[105]={0,0,200,400,1500,1000};
        char s=getch();
        if (s<'1'||s>'5'){cout<<"操作失敗"<<endl;Sleep(500);return;}
        if ((user[c].h&(1<<s-1-48))||(user[c].gold<cost[s-48])){cout<<"操作失敗!"<<endl;Sleep(500);return;}
        user[c].h|=(1<<s-1-48),user[c].gold-=cost[s-48];
        cout<<"購買成功!"<<endl;
        Sleep(500);
    }
    if (x=='U'){
        cout<<endl<<"請輸入技能編號購買技能"<<endl;
        cout<<"1 箭雨 花費0金幣"<<endl;
        cout<<"2 生命法陣 花費600金幣" <<endl;
        cout<<"3 法術傳送 花費800金幣"<<endl;
        cout<<"4 突刺 花費600金幣"<<endl;
        cout<<"5 時空躍遷 花費1000金幣"<<endl;
        int cost[105]={0,0,600,800,600,1000};
        char s=getch();
        if (s<'1'||s>'5'){cout<<"操作失敗!"<<endl;Sleep(500);return;}
        if ((user[c].u&(1<<s-1-48))||(user[c].gold<cost[s-48])){cout<<"操作失敗!"<<endl;Sleep(500);return;}
        user[c].u|=1<<(s-1-48),user[c].gold-=cost[s-48];
        cout<<"購買成功!"<<endl;
        Sleep(500);
    }
    return;
}
//神之商城
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//神域戰爭
struct warmap{
    int a,b,hp;
}mp[30][30];
int ccc[30][30];
void warout(int xx,int yy){
    system("cls");
    for (int i=1;i<=n;i++){
        for (int j=1;j<=n;j++){
            if (ccc[i][j]){
                cout<<'@';
            }
            else{
                if (mp[i][j].b){
                    cout<<mp[i][j].hp;
                }
                else if(i!=xx||j!=yy)cout<<'.';
                else{
                    cout<<"#";
                }
            }
        }
        cout<<endl;
    }
    Sleep(700);
    return;
}
void war(int c){
    int book[30][30];
    int cd[105]={0,10,30,5,8,10};
    for (int i=1;i<=n;i++)
        for (int j=1;j<=n;j++)
            mp[i][j].a=mp[i][j].b=0;
    srand((unsigned)time(NULL));
    char hc,uc;
    if (user[c].h==0||user[c].u==0){
        system("cls");
        cout<<"請先購買武器和技能"<<endl;
        Sleep(500);
        return;
    }
    system("cls");
    int sss=user[c].h;
    cout<<"請輸入編號選擇武器"<<endl;
    if (sss&1)cout<<"1 神之劍"<<endl;
    if (sss&2)cout<<"2 激光槍"<<endl;
    if (sss&4)cout<<"3 激光炮"<<endl;
    if (sss&8)cout<<"4 概率槍"<<endl;
    if (sss&16)cout<<"5 電之弓"<<endl;
    hc=getch();
    if (hc<'1'||hc>'5'||(!(sss&(1<<(hc-48-1))))){
        system("cls");
        cout<<"操作失敗!"<<hc-48-1<<endl;
        Sleep(500);
        return;
    }
    else cout<<"選擇成功!"<<endl;
    Sleep(500);
    hc-=48;
    system("cls");
    sss=user[c].u;
    cout<<"請輸入編號選擇技能"<<endl;
    if (sss&1)cout<<"1 箭雨"<<endl;
    if (sss&2)cout<<"2 生命法陣"<<endl;
    if (sss&4)cout<<"3 法術傳送"<<endl;
    if (sss&8)cout<<"4 突刺"<<endl;
    if (sss&16)cout<<"5 時空躍遷"<<endl;
    uc=getch();
    if (uc<'1'||uc>'5'||(!(sss&(1<<(uc-1-48))))){
        system("cls");
        cout<<"操作失敗!"<<endl;
        Sleep(500);
        return;
    }
    else cout<<"選擇成功!"<<endl;
    uc-=48;
    Sleep(500);
    int hp=5;
    int xx=1+rand()%n;
    int yy=1+rand()%n;
    int ucd=cd[uc],gold=0;
    int cnt=0,kill=0,killl;
    int lx=xx,ly=yy,last=0;
    while(1){
        if (cnt==200){
            system("cls");
            for (int i=1;i<=n;i++){
                for (int j=1;j<=n;j++)
                    cout<<'!';
                cout<<endl;
            }
            Sleep(1500);
            for (int i=1;i<=n;i++){
                for (int j=1;j<=n;j++)
                    mp[i][j].b=0;
            }
            cout<<"通關了!"<<endl;
            user[c].gold+=1000;
            cout<<"獲得1000金幣!"<<endl;
            Sleep(3000);
            return;
        }
        for (int i=4;i;i--)
            if (rand()%i){
                int x=1+rand()%n;
                int y=1+rand()%n;
                if (mp[x][y].b==0&&(x!=xx||y!=yy)){
                    mp[x][y].b=1;
                    mp[x][y].hp=1+rand()%9;
                }
            }
        system("cls");
        for (int i=1;i<=n;i++){
            for (int j=1;j<=n;j++)
                if (mp[i][j].b){
                    cout<<mp[i][j].hp;
                }
                else if(i!=xx||j!=yy)cout<<'.';
                else{
                    cout<<"#";
                }
            cout<<endl;
        }
        Sleep(500);
        if (hp<=0){
            system("cls");
            cout<<"神失敗了!"<<endl;
            cout<<"共進行"<<cnt<<"回合"<<endl;
            cout<<"共獲得"<<gold<<"金幣"<<endl;
            cout<<"共擊殺"<<killl<<"敵人"<<endl;
            user[c].gold+=gold;
            Sleep(2000);
            return;
        }
        cout<<"當前生命值:"<<hp<<endl;
        cout<<"當前能量值:"<<kill<<endl;
        cout<<"當前回合數:"<<cnt<<endl;
        cout<<"移動請輸入W或A或S或D"<<endl;
        cout<<"技能請輸入U 當前CD:"<<ucd<<endl;
        cout<<"攻擊請輸入I或J或K或L"<<endl;
        cout<<"消耗40能量值回覆生命請輸入H"<<endl;
        cout<<"消耗100能量值清除所有敵人請輸入C"<<endl;
        cout<<"退出游戲請輸入B"<<endl;
        char cc=getch();
        if (cc=='B'){
            system("cls");
            cout<<"共獲得"<<gold<<"金幣"<<endl;
            user[c].gold+=gold;
            Sleep(500);
            return;
        }
        if (cc=='H'&&kill>=40){
            kill-=40;
            hp=5;
            cout<<"回覆成功!"<<endl;
        }
        if (cc=='C'&&kill>=100){
            kill-=100;
            system("cls");
            for (int i=1;i<=n;i++){
                for (int j=1;j<=n;j++)
                    if (mp[i][j].b)cout<<mp[i][j].hp;
                    else if(i!=xx||j!=yy)cout<<'.';
                    else cout<<"#";
                cout<<endl;
            }
            for (int i=1;i<=n;i++)
                for (int j=1;j<=n;j++)
                    mp[i][j].b=0;
            Sleep(500);
        }
        if (cc=='W'&&xx>1&&mp[xx-1][yy].b==0)xx--;
        if (cc=='A'&&yy>1&&mp[xx][yy-1].b==0)yy--;
        if (cc=='S'&&xx<n&&mp[xx+1][yy].b==0)xx++;
        if (cc=='D'&&yy<n&&mp[xx][yy+1].b==0)yy++;
        if (cc=='U'&&ucd==0&&uc==1){
            system("cls");
            for (int i=1;i<=n;i++){
                for (int j=1;j<=n;j++)
                    if (mp[i][j].b)cout<<mp[i][j].hp;
                    else if(i!=xx||j!=yy)cout<<'.';
                    else cout<<"#";
                cout<<endl;
            }
            Sleep(500);
            ucd=cd[uc]+1;
            for (int i=1;i<=n;i++)
                for (int j=1;j<=n;j++){
                    if (mp[i][j].b){
                        mp[i][j].hp-=2;
                        if (mp[i][j].hp<=0)mp[i][j].b=0,gold+=rand()%3,kill++,killl++;
                    }
                }
        }
        if (cc=='U'&&ucd==0&&uc==2){
            hp=5;
            ucd=cd[uc]+1;
        }
        if (cc=='U'&&ucd==0&&uc==3){
            int nx=1+rand()%n,ny=1+rand()%n;
            while(mp[nx][ny].b)nx=1+rand()%n,ny=1+rand()%n;
            xx=nx,yy=ny;
            ucd=cd[uc]+1;
        }
        if (cc=='U'&&ucd==0&&uc==4){
            cout<<"請選擇突刺方向,輸入I或J或K或L"<<endl;
            char inc;
            inc=getch();
            if (inc!='I'&&inc!='J'&&inc!='K'&&inc!='L'){
                cout<<"操作失敗!"<<endl;
                Sleep(500);
            }
            int nnx=xx,nny=yy;
            if (inc=='I'){
                memset(ccc,0,sizeof(ccc));
                for (int i=1;i<=3&&xx>i;i++){
                    ccc[xx-i][yy]=1;
                    if (mp[xx-i][yy].b)gold+=rand()%3,kill++,killl++;
                    mp[xx-i][yy].b=0;
                }
                xx=max(xx-3,1);
            }
            if (inc=='J'){
                memset(ccc,0,sizeof(ccc));
                for (int i=1;i<=3&&yy>i;i++){
                    ccc[xx][yy-i]=1;
                    if (mp[xx][yy-i].b)gold+=rand()%3,kill++,killl++;
                    mp[xx][yy-i].b=0;
                }
                yy=max(yy-3,1);
            }
            if (inc=='K'){
                memset(ccc,0,sizeof(ccc));
                for (int i=1;i<=3&&xx+i<=n;i++){
                    ccc[xx+i][yy]=1;
                    if (mp[xx+i][yy].b)gold+=rand()%3,kill++,killl++;
                    mp[xx+i][yy].b=0;
                }
                xx=min(xx+3,n);
            }
            if (inc=='L'){
                memset(ccc,0,sizeof(ccc));
                for (int i=1;i<=3&&yy+i<=n;i++){
                    ccc[xx][yy+i]=1;
                    if (mp[xx][yy+i].b)gold+=rand()%3,kill++,killl++;
                    mp[xx][yy+i].b=0;
                }
                yy=min(yy+3,n);
            }
            ccc[nnx][nny]=1;
            warout(nnx,nny);
            ucd=cd[uc]+1;
        }
        if (cc=='U'&&ucd==0&&uc==5){
            cout<<"請選擇移動方向,輸入I或J或K或L"<<endl;
            char inc;
            inc=getch();
            if (inc=='I')xx=1;
            if (inc=='J')yy=1;
            if (inc=='K')xx=n;
            if (inc=='L')yy=n;
            ucd=cd[uc]+1;
            mp[xx][yy].b=0;
        }
        if (cc=='I'||cc=='J'||cc=='K'||cc=='L'){
            memset(ccc,0,sizeof(ccc));
            if (hc==1&&cc=='I'){
                if (xx>1)ccc[xx-1][yy]=1;
                if (xx>2)ccc[xx-2][yy]=1;
                warout(xx,yy);
                if (xx>1&&mp[xx-1][yy].b){
                    if (!mp[xx-1][yy].b)continue;
                    mp[xx-1][yy].hp-=8;
                    if (mp[xx-1][yy].hp<=0)gold+=rand()%3,kill++,killl++,mp[xx-1][yy].b=0;
                }
                if (xx>2&&mp[xx-2][yy].b){
                    if (!mp[xx-2][yy].b)continue;
                    mp[xx-2][yy].hp-=8;
                    if (mp[xx-2][yy].hp<=0)gold+=rand()%3,kill++,killl++,mp[xx-2][yy].b=0;
                }
            }
            if (hc==1&&cc=='J'){
                if (yy>1)ccc[xx][yy-1]=1;
                if (yy>2)ccc[xx][yy-2]=1;
                warout(xx,yy);
                if (yy>1&&mp[xx][yy-1].b){
                    if (mp[xx][yy-1].b)mp[xx][yy-1].hp-=8;
                    if (mp[xx][yy-1].b&&mp[xx][yy-1].hp<=0)gold+=rand()%3,kill++,killl++,mp[xx][yy-1].b=0;
                }
                if (yy>2&&mp[xx][yy-2].b){
                    if (mp[xx][yy-2].b)mp[xx][yy-2].hp-=8;
                    if (mp[xx][yy-2].hp<=0&&mp[xx][yy-2].b)gold+=rand()%3,kill++,killl++,mp[xx][yy-2].b=0;
                }
            }
            if (hc==1&&cc=='K'){
                if (xx+1<=n)ccc[xx+1][yy]=1;
                if (xx+2<=n)ccc[xx+2][yy]=1;
                warout(xx,yy);
                if (xx+1<=n&&mp[xx+1][yy].b){
                    if (mp[xx+1][yy].b)mp[xx+1][yy].hp-=8;
                    if (mp[xx+1][yy].hp<=0&&mp[xx+1][yy].b)gold+=rand()%3,kill++,killl++,mp[xx+1][yy].b=0;
                }
                if (xx+2<=n&&mp[xx+2][yy].b){
                    if (mp[xx+2][yy].b)mp[xx+2][yy].hp-=8;
                    if (mp[xx+2][yy].hp<=0&&mp[xx+2][yy].b)gold+=rand()%3,kill++,killl++,mp[xx+2][yy].b=0;
                }
            }
            if (hc==1&&cc=='L'){
                if (yy+1<=n)ccc[xx][yy+1]=1;
                if (yy+2<=n)ccc[xx][yy+2]=1;
                warout(xx,yy);
                if (yy+1<=n&&mp[xx][yy+1].b){
                    if (mp[xx][yy+1].b)mp[xx][yy+1].hp-=8;
                    if (mp[xx][yy+1].hp<=0&&mp[xx][yy+1].b)gold+=rand()%3,kill++,killl++,mp[xx][yy+1].b=0;
                }
                if (yy+2<=n&&mp[xx][yy+2].b){
                    if (mp[xx][yy+2].b)mp[xx][yy+2].hp-=8;
                    if (mp[xx][yy+2].hp<=0&&mp[xx][yy+2].b)gold+=rand()%3,kill++,killl++,mp[xx][yy+2].b=0;
                }
            }
            if (hc==2&&cc=='I'){
                for (int i=xx-1;i;i--)ccc[i][yy]=1;
                warout(xx,yy);
                for (int i=xx-1;i;i--){
                    if (!mp[i][yy].b)continue;
                    mp[i][yy].hp-=3+rand()%3;
                    if (mp[i][yy].hp<=0)gold+=rand()%3,kill++,killl++,mp[i][yy].b=0;
                }
            }
            if (hc==2&&cc=='J'){
                for (int i=yy-1;i;i--)ccc[xx][i]=1;
                warout(xx,yy);
                for (int i=yy-1;i;i--){
                    if (!mp[xx][i].b)continue;
                    mp[xx][i].hp-=3+rand()%3;
                    if (mp[xx][i].hp<=0)gold+=rand()%3,kill++,killl++,mp[xx][i].b=0;
                }
            }
            if (hc==2&&cc=='K'){
                for (int i=xx+1;i<=n;i++)ccc[i][yy]=1;
                warout(xx,yy);
                for (int i=xx+1;i<=n;i++){
                    if (!mp[i][yy].b)continue;
                    mp[i][yy].hp-=3+rand()%3;
                    if (mp[i][yy].hp<=0)gold+=rand()%3,kill++,killl++,mp[i][yy].b=0;
                }
            }
            if (hc==2&&cc=='L'){
                for (int i=yy+1;i<=n;i++)ccc[xx][i]=1;
                warout(xx,yy);
                for (int i=yy+1;i<=n;i++){
                    if (!mp[xx][i].b)continue;
                    mp[xx][i].hp-=3+rand()%3;
                    if (mp[xx][i].hp<=0)gold+=rand()%3,kill++,killl++,mp[xx][i].b=0;
                }
            }
            if (hc==3&&cc=='I'){
                for (int i=xx-1;i;i--){
                    ccc[i][yy-1]=1;
                    ccc[i][yy]=1;
                    ccc[i][yy+1]=1;
                }
                warout(xx,yy);
                for (int i=xx-1;i;i--){
                    if (mp[i][yy].b){
                        mp[i][yy].hp-=2+rand()%2;
                        if (mp[i][yy].hp<=0)gold+=rand()%3,kill++,killl++,mp[i][yy].b=0;
                    }
                    if (mp[i][yy-1].b){
                        mp[i][yy-1].hp-=2+rand()%2;
                        if (mp[i][yy-1].hp<=0)gold+=rand()%3,kill++,killl++,mp[i][yy-1].b=0;
                    }
                    if (mp[i][yy+1].b){
                        mp[i][yy+1].hp-=2+rand()%2;
                        if (mp[i][yy+1].hp<=0)gold+=rand()%3,kill++,killl++,mp[i][yy+1].b=0;
                    }
                }
            }
            if (hc==3&&cc=='J'){
                for (int i=yy-1;i;i--){
                    ccc[xx][i]=1;
                    ccc[xx-1][i]=1;
                    ccc[xx+1][i]=1;
                }
                warout(xx,yy);
                for (int i=yy-1;i;i--){
                    if (mp[xx][i].b){
                        mp[xx][i].hp-=2+rand()%2;
                        if (mp[xx][i].hp<=0)gold+=rand()%3,kill++,killl++,mp[xx][i].b=0;
                    }
                    if (mp[xx-1][i].b){
                        mp[xx-1][i].hp-=2+rand()%2;
                        if (mp[xx-1][i].hp<=0)gold+=rand()%3,kill++,killl++,mp[xx-1][i].b=0;
                    }
                    if (mp[xx+1][i].b){
                        mp[xx+1][i].hp-=2+rand()%2;
                        if (mp[xx+1][i].hp<=0)gold+=rand()%3,kill++,killl++,mp[xx+1][i].b=0;
                    }
                }
            }
            if (hc==3&&cc=='K'){
                for (int i=xx+1;i<=n;i++){
                    ccc[i][yy-1]=1;
                    ccc[i][yy]=1;
                    ccc[i][yy+1]=1;
                }
                warout(xx,yy);
                for (int i=xx+1;i<=n;i++){
                    if (mp[i][yy].b){
                        mp[i][yy].hp-=2+rand()%2;
                        if (mp[i][yy].hp<=0)gold+=rand()%3,kill++,killl++,mp[i][yy].b=0;
                    }
                    if (mp[i][yy-1].b){
                        mp[i][yy-1].hp-=2+rand()%2;
                        if (mp[i][yy-1].hp<=0)gold+=rand()%3,kill++,killl++,mp[i][yy-1].b=0;
                    }
                    if (mp[i][yy+1].b){
                        mp[i][yy+1].hp-=2+rand()%2;
                        if (mp[i][yy+1].hp<=0)gold+=rand()%3,kill++,killl++,mp[i][yy+1].b=0;
                    }
                }
            }
            if (hc==3&&cc=='L'){
                for (int i=yy+1;i<=n;i++){
                    ccc[xx-1][i]=1;
                    ccc[xx][i]=1;
                    ccc[xx+1][i]=1;
                }
                warout(xx,yy);
                for (int i=yy+1;i<=n;i++){
                    if (mp[xx][i].b){
                        mp[xx][i].hp-=2+rand()%2;
                        if (mp[xx][i].hp<=0)gold+=rand()%3,kill++,killl++,mp[xx][i].b=0;
                    }
                    if (mp[xx-1][i].b){
                        mp[xx-1][i].hp-=2+rand()%2;
                        if (mp[xx-1][i].hp<=0)gold+=rand()%3,kill++,killl++,mp[xx-1][i].b=0;
                    }
                    if (mp[xx+1][i].b){
                        mp[xx+1][i].hp-=2+rand()%2;
                        if (mp[xx+1][i].hp<=0)gold+=rand()%3,kill++,killl++,mp[xx+1][i].b=0;
                    }
                }
            }
            if (hc==4&&cc=='I'){
                for (int i=xx-1;i;i--)ccc[i][yy]=1;
                warout(xx,yy);
                for (int i=xx-1;i;i--){
                    if (!mp[i][yy].b)continue;
                    int r=rand()%3;
                    mp[i][yy].hp-=mp[i][yy].hp*r;
                    if (mp[i][yy].hp<=0)gold+=rand()%3,kill++,killl++,mp[i][yy].b=0;
                }
            }
            if (hc==4&&cc=='J'){
                for (int i=yy-1;i;i--)ccc[xx][i]=1;
                warout(xx,yy);
                for (int i=yy-1;i;i--){
                    if (!mp[xx][i].b)continue;
                    int r=rand()%3;
                    mp[xx][i].hp-=mp[xx][i].hp*r;
                    if (mp[xx][i].hp<=0)gold+=rand()%3,kill++,killl++,mp[xx][i].b=0;
                }
            }
            if (hc==4&&cc=='K'){
                for (int i=xx+1;i<=n;i++)ccc[i][yy]=1;
                warout(xx,yy);
                for (int i=xx+1;i<=n;i++){
                    if (!mp[i][yy].b)continue;
                    int r=rand()%3;
                    mp[i][yy].hp-=mp[i][yy].hp*r;
                    if (mp[i][yy].hp<=0)gold+=rand()%3,kill++,killl++,mp[i][yy].b=0;
                }
            }
            if (hc==4&&cc=='L'){
                for (int i=yy+1;i<=n;i++)ccc[xx][i]=1;
                warout(xx,yy);
                for (int i=yy+1;i<=n;i++){
                    if (!mp[xx][i].b)continue;
                    int r=rand()%3;
                    mp[xx][i].hp-=mp[xx][i].hp*r;
                    if (mp[xx][i].hp<=0)gold+=rand()%3,kill++,killl++,mp[xx][i].b=0;
                }
            }
            if (hc==5&&cc=='I'){
                int i;
                for (i=xx;i;i--)
                    if (mp[i][yy].b)break;
                mp[i][yy].hp-=5;
                if (mp[i][yy].hp<=0)gold+=rand()%3,kill++,killl++,mp[i][yy].b=0;
                if (i){
                    memset(ccc,0,sizeof(ccc));
                    ccc[i][yy]=1;
                    warout(xx,yy);
                    if (rand()%10==0){
                        memset(ccc,0,sizeof(ccc));
                        for (int i=1;i<=n;i++)
                            for (int j=1;j<=n;j++)
                                if (mp[i][j].b){
                                    mp[i][j].hp--;
                                    if (mp[i][j].hp<=0)gold+=rand()%3,kill++,killl++,mp[i][j].b=0;
                                }
                        for (int i=1;i<=n;i++)
                            for (int j=1;j<=n;j++)
                                ccc[i][j]=1;
                        warout(xx,yy);
                    }
                }
            }
            if (hc==5&&cc=='J'){
                int i;
                for (i=yy;i;i--)
                    if (mp[xx][i].b)break;
                mp[xx][i].hp-=5;
                if (mp[xx][i].hp<=0)gold+=rand()%3,kill++,killl++,mp[xx][i].b=0;
                if (i){
                    memset(ccc,0,sizeof(ccc));
                    ccc[xx][i]=1;
                    warout(xx,yy);
                    if (rand()%10==0){
                        memset(ccc,0,sizeof(ccc));
                        for (int i=1;i<=n;i++)
                            for (int j=1;j<=n;j++)
                                if (mp[i][j].b){
                                    mp[i][j].hp--;
                                    if (mp[i][j].hp<=0)gold+=rand()%3,kill++,killl++,mp[i][j].b=0;
                                }
                        for (int i=1;i<=n;i++)
                            for (int j=1;j<=n;j++)
                                ccc[i][j]=1;
                        warout(xx,yy);
                    }
                }
            }
            if (hc==5&&cc=='K'){
                int i;
                for (i=xx;i<=n;i++)
                    if (mp[i][yy].b)break;
                mp[i][yy].hp-=5;
                if (mp[i][yy].hp<=0)gold+=rand()%3,kill++,killl++,mp[i][yy].b=0;
                if (i<=n){
                    memset(ccc,0,sizeof(ccc));
                    ccc[i][yy]=1;
                    warout(xx,yy);
                    if (rand()%10==0){
                        memset(ccc,0,sizeof(ccc));
                        for (int i=1;i<=n;i++)
                            for (int j=1;j<=n;j++)
                                if (mp[i][j].b){
                                    mp[i][j].hp--;
                                    if (mp[i][j].hp<=0)gold+=rand()%3,kill++,killl++,mp[i][j].b=0;
                                }
                        for (int i=1;i<=n;i++)
                            for (int j=1;j<=n;j++)
                                ccc[i][j]=1;
                        warout(xx,yy);
                    }
                }
            }
            if (hc==5&&cc=='L'){
                int i;
                for (i=yy;i<=n;i++)
                    if (mp[xx][i].b)break;
                mp[xx][i].hp-=5;
                if (mp[xx][i].hp<=0)gold+=rand()%3,kill++,killl++,mp[xx][i].b=0;
                if (i<=n){
                    memset(ccc,0,sizeof(ccc));
                    ccc[xx][i]=1;
                    warout(xx,yy);
                    if (rand()%10==0){
                        memset(ccc,0,sizeof(ccc));
                        for (int i=1;i<=n;i++)
                            for (int j=1;j<=n;j++)
                                if (mp[i][j].b){
                                    mp[i][j].hp--;
                                    if (mp[i][j].hp<=0)gold+=rand()%3,kill++,killl++,mp[i][j].b=0;
                                }
                        for (int i=1;i<=n;i++)
                            for (int j=1;j<=n;j++)
                                ccc[i][j]=1;
                        warout(xx,yy);
                    }
                }
            }
        }
        memset(book,0,sizeof(book));
        for (int i=1;i<=n;i++)
            for (int j=1;j<=n;j++){
                if (book[i][j])continue;
                if (!mp[i][j].b)continue;
                int movex[4]={1,0,0,-1};
                int movey[4]={0,1,-1,0};
                int s=rand()%4;
                int mmm=rand()%4;
                int nx,ny;
                if (!mmm)nx=i+movex[s],ny=j+movey[s];
                else{
                    nx=i,ny=j;
                    int mmmm=rand()%2;
                    if (nx==xx)mmmm=1;
                    if (nx==yy)mmmm=0;
                    if (mmmm==0){
                        if (nx<xx)nx++;
                        if (nx>xx)nx--;
                    }
                    if (mmmm==1){
                        if (ny<yy)ny++;
                        if (ny>yy)ny--;
                    }
                }
                if (nx<1||ny<1||nx>n||ny>n)continue;
                book[nx][ny]=1;
                if (nx==xx&&ny==yy){
                    hp-=2;
                    mp[i][j].b=0;
                    system("cls");
                    for (int i=1;i<=n;i++){
                        for (int j=1;j<=n;j++)
                            if (mp[i][j].b)cout<<mp[i][j].hp;
                            else if(i!=xx||j!=yy)cout<<'.';
                            else cout<<"!";
                        cout<<endl;
                    }
                    Sleep(500);
                    continue;
                }
                if (!mp[nx][ny].b){
                    mp[i][j].b=0;
                    mp[nx][ny].b=1;
                    mp[nx][ny].hp=mp[i][j].hp;
                }
            }
        if (xx==lx&&yy==ly)last++;
        else last=0,lx=xx,ly=yy;
        if (last>=5){
            system("cls");
                for (int i=1;i<=n;i++){
                    for (int j=1;j<=n;j++)
                        if (mp[i][j].b)cout<<mp[i][j].hp;
                        else if(i!=xx||j!=yy)cout<<'.';
                        else cout<<"!";
                    cout<<endl;
                }
            Sleep(500);
            hp--;
        }
        ucd--;
        ucd=max(ucd,0);
        cnt++;
    }
    return;
}
//神域戰爭
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void game2(){
    char x;
    while(x!='B'&&x!='b'){
        cout<<"退出並保存游戲請輸入:B"<<endl;
        cout<<"打開神之商城請輸入:S"<<endl;
        cout<<"進入神域戰爭請輸入:W"<<endl;
        x=getch();
        if (x=='S'||x=='s')shop(nowuser);
        if (x=='W'||x=='w')war(nowuser);
        system("cls");
    }
    return;
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//註冊 登錄
char rere[105];
bool issame(string x){
    for (int i=1;i<x.size();i++)
        if (rere[i]!=x[i])return 0;
    return 1;
}
bool charsame(char a[105],char b[105],int blen){
    for (int i=0;i<blen;i++)if (a[i]!=b[i])return 0;
    return 1;
}
int canfind(int len){
    int ansi=0;
    for (int i=1;i<=usertot;i++)
        if (charsame(rere,user[i].name,user[i].namelen)&&len==user[i].namelen)ansi=i;
    return ansi;
}
bool login_register(){
    char k=getch();
    while(k!='1'&&k!='2'){
        system("cls");
        cout<<"抱歉,請您再試一次"<<endl;
        cout<<"登陸請按1"<<' '<<"用戶名"<<' '<<"密碼"<<endl;
        cout<<"註冊請按2"<<' '<<"用戶名"<<' '<<"密碼"<<endl;
        k=getch();
    }
    system("cls");
    if (k=='1'){
        if (usertot==0){cout<<"ERROR"<<endl;return 0;}
        cout<<"請輸入用戶名:"<<endl;
        int len;
        scanf("%s",rere);
        len=strlen(rere);
        system("cls");
        while(!canfind(len)){
            cout<<"抱歉,未找到用戶名"<<endl;
            cout<<"請重新輸入"<<endl;
            scanf("%s",rere);
            len=strlen(rere);
            system("cls");
        }
        nowuser=canfind(len);

您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • (軟體環境) 『系統』Windows 10 x64 『JAVA』JDK 1.8.0_91 『Eclipse』 Eclipse-oxygen 『Maven』 apache-maven-3.6.3 『Jetty』jetty-distribution-9.4.26 (配置過程) 一、JAVA和Maven的 ...
  • 本文首發於公眾號「Python知識圈」,如需轉載,請在公眾號聯繫作者授權。 前言 上一篇文章整理了的公眾號所有文章的導航鏈接,其實如果手動整理起來的話,是一件很費力的事情,因為公眾號里添加文章的時候只能一篇篇的選擇,是個單選框。 面對幾百篇的文章,這樣一個個選擇的話,是一件苦差事。 pk哥作為一個 ...
  • JavaSE學習筆記(9) 集合類和泛型 1、Collection集合 集合概述 在前面我們已經學習過並使用過集合 ,那麼集合到底是什麼呢? 集合 :集合是java中提供的一種容器,可以用來存儲多個數據。 集合和數組既然都是容器,它們有什麼區別呢? 數組的長度是固定的。集合的長度是可變的。 數組中存 ...
  • JavaSE學習筆記(8) 常用類 1、Object類 類是Java語言中的根類,即所有類的父類。它中描述的所有方法子類都可以使用。在對象實例化的時候,最終找的父類就是Object。 如果一個類沒有特別指定父類,那麼預設則繼承自Object類。例如: 根據JDK源代碼及Object類的API文檔,O ...
  • 猴博士4小時講完C語言視頻教程,一共有9節課。 目錄結構如下: 目錄:/2020030-猴博士4小時講完C語言 [1G] ┣━━1.C語言基本語句(上)(更多資源訪問:www.jimeng365.cn).mp4 [87.1M] ┣━━2.C語言基本語句(下)(更多資源訪問:www.jimeng365 ...
  • 1、下載地址 http://www.erlang.org/downloads 2、下載文件 下載 OTP 22.2 Windows 64 bit Binary File 3、配置環境變數 將下載的安裝包文件安裝完成上設置環境變數,配置環境變數如下圖,將Erlang的安裝路徑下的bin文件夾的路徑添加 ...
  • 一.匿名函數 1.定義:定義函數的時候不需要定義函數名 2.具體例子: #普通函數 def add(x,y): return x + y #匿名函數 lambda x,y: x + y 調用匿名函數: f = lambda x,y: x + y #賦值後可以調用 print(f(1,2) lambd ...
  • 最近在學習C和C++,除了在寫OS的時候用到外,寫演算法的時候也會用到,整理記錄C和C++讀取數據的各種方式。 [TOC] 文章較長,總結稍微詳細了一點。 c 輸出 printf() 在 中包含最經典的輸出函數 格式化輸出,在 中格式化輸出的格式: 1)類型 | 格式字元 | 含義 | | | | | ...
一周排行
    -Advertisement-
    Play Games
  • Dapr Outbox 是1.12中的功能。 本文只介紹Dapr Outbox 執行流程,Dapr Outbox基本用法請閱讀官方文檔 。本文中appID=order-processor,topic=orders 本文前提知識:熟悉Dapr狀態管理、Dapr發佈訂閱和Outbox 模式。 Outbo ...
  • 引言 在前幾章我們深度講解了單元測試和集成測試的基礎知識,這一章我們來講解一下代碼覆蓋率,代碼覆蓋率是單元測試運行的度量值,覆蓋率通常以百分比表示,用於衡量代碼被測試覆蓋的程度,幫助開發人員評估測試用例的質量和代碼的健壯性。常見的覆蓋率包括語句覆蓋率(Line Coverage)、分支覆蓋率(Bra ...
  • 前言 本文介紹瞭如何使用S7.NET庫實現對西門子PLC DB塊數據的讀寫,記錄了使用電腦模擬,模擬PLC,自至完成測試的詳細流程,並重點介紹了在這個過程中的易錯點,供參考。 用到的軟體: 1.Windows環境下鏈路層網路訪問的行業標準工具(WinPcap_4_1_3.exe)下載鏈接:http ...
  • 從依賴倒置原則(Dependency Inversion Principle, DIP)到控制反轉(Inversion of Control, IoC)再到依賴註入(Dependency Injection, DI)的演進過程,我們可以理解為一種逐步抽象和解耦的設計思想。這種思想在C#等面向對象的編 ...
  • 關於Python中的私有屬性和私有方法 Python對於類的成員沒有嚴格的訪問控制限制,這與其他面相對對象語言有區別。關於私有屬性和私有方法,有如下要點: 1、通常我們約定,兩個下劃線開頭的屬性是私有的(private)。其他為公共的(public); 2、類內部可以訪問私有屬性(方法); 3、類外 ...
  • C++ 訪問說明符 訪問說明符是 C++ 中控制類成員(屬性和方法)可訪問性的關鍵字。它們用於封裝類數據並保護其免受意外修改或濫用。 三種訪問說明符: public:允許從類外部的任何地方訪問成員。 private:僅允許在類內部訪問成員。 protected:允許在類內部及其派生類中訪問成員。 示 ...
  • 寫這個隨筆說一下C++的static_cast和dynamic_cast用在子類與父類的指針轉換時的一些事宜。首先,【static_cast,dynamic_cast】【父類指針,子類指針】,兩兩一組,共有4種組合:用 static_cast 父類轉子類、用 static_cast 子類轉父類、使用 ...
  • /******************************************************************************************************** * * * 設計雙向鏈表的介面 * * * * Copyright (c) 2023-2 ...
  • 相信接觸過spring做開發的小伙伴們一定使用過@ComponentScan註解 @ComponentScan("com.wangm.lifecycle") public class AppConfig { } @ComponentScan指定basePackage,將包下的類按照一定規則註冊成Be ...
  • 操作系統 :CentOS 7.6_x64 opensips版本: 2.4.9 python版本:2.7.5 python作為腳本語言,使用起來很方便,查了下opensips的文檔,支持使用python腳本寫邏輯代碼。今天整理下CentOS7環境下opensips2.4.9的python模塊筆記及使用 ...