0
已采纳
刘欣然
高级光能
高级光能
在CSDN博客里搜C++游戏源代码可得游戏源码
推荐(我把代码复制进下面的网址)
没了
以上摘自CSDN博客
DEV自带游戏
打开DEVC++-文件-项目-Console-Jackpot
(只不过是全英文的,也挺好玩)
刘欣然在2020-05-02 12:01:22追加了内容
打开DEVC++-新建-文件-项目-Console-Jackpot
0
0
0
李致远
高级光能
高级光能
1 注意保存为.c形式
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
int main(void)
{
int random();
int mopai(int shan);
int yourchusha(int shan);
int i,xingcan=0,temp,choice;
int yoursha=0,yourshan=0;
int itssha=0,itsshan=0;
int yourhp=4,itshp=4;
printf("三国杀简易版:;n");
printf("开始游戏:;n");
srand( (unsigned)time( NULL ) );
for(i=1;i<=4;i++)
{
random();//方法可返回介于 0 ~ 1 之间的一个随机数。
if(!random())
yourshan+=1;
else yoursha+=1;
}
for(i=1;i<=4;i++)
{
random();
if(!random())
itsshan+=1;
else itssha+=1;
}
printf("你的手牌:杀%d张,闪%d张;t",yoursha,yourshan);
printf("计算机的手牌:%d张;n",itssha+itsshan);
printf("你的体力:%d;t",yourhp);
printf("计算机的体力:%d;n",itshp);
while(yourhp&&itshp)
{
printf(";n你的行动开始:;n");
printf(";n摸牌阶段:;n");
temp=mopai(xingcan);
yourshan+=temp;
yoursha+=(2-temp);
xingcan=0;
printf("你的手牌:杀%d张,闪%d张;n",yoursha,yourshan);
printf(";n按任意键继续;n");
getch();
system("cls");
printf("你的手牌:杀%d张,闪%d张;t",yoursha,yourshan);
printf("计算机的手牌:%d张;n",itssha+itsshan);
printf("你的体力:%d;t",yourhp);
printf("计算机的体力:%d;n",itshp);
printf(";n出牌阶段:;n");
printf("请选择:;n");
printf("1.出杀 2.弃牌;n");
while(1)
{
scanf("%d",&choice);
if(choice!=1&&choice!=2)
printf("输入错误,请重新输入;n");
else break;
}
if(choice==1)
{
if(yoursha)
{
yoursha-=1;
if(yourchusha(itsshan))
itsshan-=1;
else
{
itshp-=1;
}
}
else printf("你没有杀,请弃牌;n");
}
if(!itshp)
break;
printf(";n按任意键继续;n");
getch();
system("cls");
printf("你的手牌:杀%d张,闪%d张;t",yoursha,yourshan);
printf("计算机的手牌:%d张;n",itssha+itsshan);
printf("你的体力:%d;t",yourhp);
printf("计算机的体力:%d;n",itshp);
printf("弃牌阶段:;n");
while(yoursha+yourshan-yourhp>0)
{
printf("你需要弃掉%d张卡牌,请逐张弃牌:;n",yoursha+yourshan-yourhp);
printf("1.弃一张杀 2.弃一张闪;n");
while(1)
{
scanf("%d",&choice);
if(choice!=1&&choice!=2)
printf("输入错误,请重新输入;n");
else break;
}
switch(choice)
{
case 1:
{
if(yoursha)
yoursha-=1;
else printf("你没有杀,请重新选择;n");
break;
}
case 2:
{
if(yourshan)
yourshan-=1;
else printf("你没有闪,请重新选择;n");
break;
}
}
}
printf("你的行动结束。;n");
printf(";n按任意键继续;n");
getch();
system("cls");
printf("你的手牌:杀%d张,闪%d张;t",yoursha,yourshan);
printf("计算机的手牌:%d张;n",itssha+itsshan);
printf("你的体力:%d;t",yourhp);
printf("计算机的体力:%d;n",itshp);
printf("计算机的行动开始:;n");
printf("摸牌阶段:;n");
temp=mopai(xingcan);
itsshan+=temp;
itssha+=(2-temp);
xingcan=0;
printf("计算机手牌数:%d张;n",itssha+itsshan);
printf(";n按任意键继续;n");
getch();
system("cls");
printf("你的手牌:杀%d张,闪%d张;t",yoursha,yourshan);
printf("计算机的手牌:%d张;n",itssha+itsshan);
printf("你的体力:%d;t",yourhp);
printf("计算机的体力:%d;n",itshp);
printf("出牌阶段:;n");
if(itssha)
{
itssha-=1;
printf("杀;n");
printf("计算机对你出了一张杀,请出一张闪;n");
printf("1.确定 2.取消;n");
while(1)
{
scanf("%d",&choice);
if(choice!=1&&choice!=2){
printf("输入错误,请重新输入;n");
system("cls");
printf("你的手牌:杀%d张,闪%d张;t",yoursha,yourshan);
printf("计算机的手牌:%d张;n",itssha+itsshan);
printf("你的体力:%d;t",yourhp);
printf("计算机的体力:%d;n",itshp);
}
else break;
}
switch(choice)
{
case 1:
{
if(yourshan)
{
yourshan-=1;
printf("闪;n");
break;
}
else printf("你没有闪;n");
}
case 2:
{
yourhp-=1;
printf("计算机对你造成一点伤害;n");
}
}
}
if(!yourhp)
break;
printf("计算机手牌数:%d张;n",itssha+itsshan);
printf("弃牌阶段:;n");
if(itssha+itsshan-itshp>0)
{
if(itshp>itsshan)
{
printf("计算机弃杀%d张;n",itssha+itsshan-itshp);
itssha-=(itssha+itsshan-itshp);
}
else
{
printf("计算机弃杀%d张,闪%d张;n",itssha,itsshan-itshp);
itssha=0;
itsshan=itshp;
}
}
printf("计算机的行动结束。;n");
printf(";n按任意键继续;n");
getch();
system("cls");
printf("你的手牌:杀%d张,闪%d张;t",yoursha,yourshan);
printf("计算机手牌数:%d张;n",itssha+itsshan);
printf("你的体力:%d;t",yourhp);
printf("计算机的体力:%d;n",itshp);
}
if(!yourhp)
printf("很遗憾,计算机击败了你;n");
else printf("恭喜你,你击败了计算机;n");
printf("游戏结束,欢迎下次再来!;n");
printf(";n按任意键退出。");
getch();
return 0;
}
int random()
{
return rand()%3;
}
int mopai(int shan)
{
int i;
srand( (unsigned)time( NULL ) );
for(i=1;i<=2;i++)
{
random();
if(!random())
shan+=1;
}
return shan;
}
int yourchusha(int shan)
{
printf("杀 ");
if(shan)
{
printf("闪;n");
return 1;
}
else
{
printf("您对计算机造成一点伤害;n");
return 0;
}
}
2 小飞机
#include<stdio.h>
#include<string.h>
#include<conio.h>
#include<windows.h>
#include<stdlib.h>
#define MAX 100
long long int speed = 0;//控制敌机的速度
int position_x, position_y;//飞机的所在位置
int high, width;//地图的大小
int bullet_x, bullet_y;//子弹的位置
int enemy_x, enemy_y;//敌人的位置
int map[MAX][MAX];
/*0表示空白,1表示战机*的区域,2表示敌人战机的位置。
3表示上下围墙,4表示左右围墙,5表示子弹的位置*/
int score;
void starup()//初始化所有的信息
{
high = 20;
width = 30;
position_x = high / 2;
position_y = width / 2;
bullet_x = 0;
bullet_y = position_y;
enemy_x = 2;
enemy_y = position_y - 1;
score = 0;
}
void startMap()
{
int i, j;
for (i = 1; i <= high - 1; i++)
{
map[i][1] = 4;
for (j = 2; j <= width - 1; j++)
map[i][j] = 0;
map[i][width] = 4;
}
//下方围墙的初始化
i = high;
for (j = 1; j <= width; j++)
map[i][j] = 3;
map[bullet_x][bullet_y] = 5;
/*这里是战机大小的初始化开始*/
map[position_x - 1][position_y] = 1;
i = position_x;
for (j = position_y - 2; j <= position_y + 2; j++)
map[i][j] = 1;
map[position_x + 1][position_y - 1] = 1;
map[position_x + 1][position_y + 1] = 1;
/*** 初始化结束 **/
/* 敌人战机的初始化 */
map[enemy_x][enemy_y] = 2;
map[enemy_x - 1][enemy_y - 1] = 2;
map[enemy_x - 1][enemy_y + 1] = 2;
/* 敌人战机初始化结束*/
}
void HideCursor()//隐藏光标
{
CONSOLE_CURSOR_INFO cursor_info = { 1, 0 };
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info);
}
void gotoxy(int x, int y)//清理一部分屏幕
{
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
COORD pos;
pos.X = x;
pos.Y = y;
SetConsoleCursorPosition(handle, pos);
}
void updateWithoutInput()//于输入无关的跟新
{
if (bullet_x > 0)
bullet_x--;
if ((bullet_x == enemy_x) && (bullet_y == enemy_y))//当敌人的飞机被击中时
{
score++;
enemy_x = 0;
enemy_y = rand() % width;
bullet_x = 0;
}
if (enemy_x > high)//当飞机超出区域
{
enemy_x = 0;
enemy_y = rand() % width;
}
if (speed == 1)
for (int i = 1; i <= 10000; i++)//用来控制敌机的速度
{
for (int j = 1; j <= 1000; j++)
{
speed = 1;
}
}
speed = 0;
if (speed == 0)
{
enemy_x++;
speed = 1;
}
}
void updateWithInput()//与输入有关的更新
{
char input;
if (kbhit())//在VC6.0++下,为_kbhit()
{
input = getch();//在VC6.0++下为_getch();
if (input == 'a')
position_y--;
if (input == 's')
position_x++;
if (input == 'd')
position_y++;
if (input == 'w')
position_x--;
if (input == ' ')
{
bullet_x = position_x - 1;
bullet_y = position_y;
}
}
}
void show()//展示的内容
{
gotoxy(0, 0);
int i, j;
for (i = 1; i <= high; i++)
{
for (j = 1; j <= width; j++)
{
if (map[i][j] == 0)
printf(" ");
if (map[i][j] == 1)
printf("*");
if (map[i][j] == 2)
printf("#");
if (map[i][j] == 3)
printf("~");
if (map[i][j] == 4)
printf("|");
if (map[i][j] == 5)
printf("|");
}
printf("\n");
}
printf("\n你的得分:%d\n\n", score);
printf("操作说明: ASDW分别操作 左下右上四个的移动\n");
printf("**空格是发出子弹**\n");
}
int main()
{
starup();
while (1)
{
HideCursor();
startMap();
show();
updateWithoutInput();
updateWithInput();
}
return 0;
}
3 注意保存为.c格式
#include "game.h"
void print_board(char board[][COL+2],int row,int col)
{
int i = 1;
int j = 0;
printf(" ");
for(;i<=COL;i++)
printf("%3d",i);
printf("\n");
printf(" ");
for(i=0;i<ROW;i++)
printf("---");
printf("\n");
for(i = 1;i<=ROW;i++)
{
printf("%2d|",i);
for(j = 1;j<=COL;j++)
{
printf("%2c|",board[i][j]);
}
printf("\n");
}
}
void lay_mines(char mine[][COL+2],int row,int col,int a)
{
int x;
int y;
int count = 0;
srand((unsigned long)time(NULL));
do{
x = (rand() % (ROW))+1;
y = (rand() % (COL))+1;
if(mine[x][y] == '0')
{
mine[x][y] = '1';
count++;
}
}while(count < (a*MINE_NUM));
}
int get_mine_num(char mine[][COL+2],int row,int col,int x,int y)
{
int num = 0;
num = (mine[x-1][y-1] - '0') + (mine[x-1][y] - '0') + (mine[x-1][y+1] - '0') + (mine[x][y-1] - '0') + (mine[x][y+1] - '0') + (mine[x+1][y-1] - '0') + (mine[x+1][y] - '0') + (mine[x+1][y+1] - '0');
return num;
}
void game()
{
int i = 1;
int x,y;
int win = 0;
do
{
char mine[ROW+2][COL+2];
char show[ROW+2][COL+2];
memset(mine,'0',(ROW+2)*(COL+2));
memset(show,'*',(ROW+2)*(COL+2));
printf("第%d关\n",i);
lay_mines(mine,ROW+2,COL+2,i);
do{
system("cls");
print_board(show,ROW+2,COL+2);
printf("Please input your coordinate:<x,y>");
scanf("%d%d",&x,&y);
if(x>=1&&x<=10&&y>=1&&y<=10)
{
if(mine[x][y] == '1')
{
printf("It's too bad!Game over!\n");
print_board(mine,ROW+2,COL+2);
goto END;
}
else
{
int count = get_mine_num(mine,ROW+2,COL+2,x,y);
show[x][y] = count + '0';
win++;
if(ROW*COL-i*MINE_NUM == win)
{
printf("Congratulations!You win!\n");
i++;
break;
}
}
}
}while(1);
}while(i<=4);
END:
printf("Do you want to play again?\n");
}
4 海战棋(力鼎)
#include <cstdio>
#include <ctime> //rand()%(x) 0~x-1 int
#include <windows.h> //停顿:Sleep();
#include <cstdlib> //清屏:system("cls");
#include <conio.h> //getch(); char
#include <iostream>
#include <cstring> //未知 :□; 打中 :◎; 未打中:○ 船:★;
using namespace std;
int rest[3][5],r1,r2; //rest[1]:玩家的海域; rest[2]:电脑的海域 r1:玩家还剩船数; r2:电脑还剩船数
int b1[12][12],b2[12][12]; //0:空海; 1:船只; 2:打中; 3:边界 4:未打中 5:沉船
int c1[12][12],c2[12][12]; //c1:玩家海域的颜色 c2:电脑海域颜色
int fx[8][2]={{0,1},{1,0},{0,-1},{-1,0},{1,1},{-1,-1},{1,-1},{-1,1}};
int now[2][2]; //now[左/右][x/y] 光标
string a1[12][12],a2[12][12];
int fd [500][2],head=0,tail=0;
const long long wdmm=956454236985412563;
long long cjzt=0,wdm;
void color(int a)//颜色函数
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),a);
}
void gotoxy(int x,int y)//位置函数(整个界面)(行为x 列为y)
{
COORD pos;
pos.X=2*(y);
pos.Y=x;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos);
}
void gotoxy1(int x,int y)//位置函数(左边棋盘)(行为x 列为y)
{
COORD pos;
pos.X=2*(y+5);
pos.Y=x+1;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos);
}
void gotoxy2(int x,int y)//位置函数(右边棋盘)(行为x 列为y)
{
COORD pos;
pos.X=2*(y+18);
pos.Y=x+1;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos);
}
void check2(int x,int y){
int k=0,kx,ky,f=1;
for (int i=0; i<=3; i++){
if (b2[x+fx[i][0]][y+fx[i][1]]==2) k=i;
if (b2[x+fx[i][0]][y+fx[i][1]]==1) f=0;
}
for (kx=x,ky=y; b2[kx][ky]==2; kx+=fx[k][0],ky+=fx[k][1]);
if (b2[kx][ky]==1) f=0;
if (f){
int w=0;
color(12);
for (kx=x,ky=y; b2[kx][ky]==2; kx+=fx[k][0],ky+=fx[k][1]){
gotoxy2(kx,ky);
a2[kx][ky]="※";
c2[kx][ky]=12;
cout <<"※";
w++;
}
for (kx=x+fx[(k+2)%4][0],ky=y+fx[(k+2)%4][1]; b2[kx][ky]==2; kx+=fx[(k+2)%4][0],ky+=fx[(k+2)%4][1]){
gotoxy2(kx,ky);
a2[kx][ky]="※";
c2[kx][ky]=12;
cout <<"※";
w++;
}
if (w>0){
rest[2][w]--;
r2--;
if (rest[2][w]>0) color(14); else color(11);
gotoxy2(5-w,16); printf("*%d",rest[2][w]);
}
}
}
int move1(){
if (r1*r2==0) return(1);
color(5); gotoxy1(14,4); printf("电脑开炮");
color(13); gotoxy2(14,4); printf("玩家开炮");
int kx=now[1][0],ky=now[1][1],lastx,lasty,f=1;
char ch;
gotoxy2(kx,ky); color(11); if (a2[kx][ky]!=" ")cout <<a2[kx][ky]; else cout <<"▂"; gotoxy2(kx,ky);
while (f){
ch=getch();
if (ch=='1' || ch=='a'){kx=now[1][0]+fx[2][0]; ky=now[1][1]+fx[2][1];}
if (ch=='2' || ch=='s'){kx=now[1][0]+fx[1][0]; ky=now[1][1]+fx[1][1];}
if (ch=='3' || ch=='d'){kx=now[1][0]+fx[0][0]; ky=now[1][1]+fx[0][1];}
if (ch=='5' || ch=='w'){kx=now[1][0]+fx[3][0]; ky=now[1][1]+fx[3][1];}
if (kx>0 && kx<=10 && ky>0 && ky<=10){
gotoxy2(now[1][0],now[1][1]); color(c2[now[1][0]][now[1][1]]); cout <<a2[now[1][0]][now[1][1]];
gotoxy2(kx,ky); color(11); if (a2[kx][ky]!=" ")cout <<a2[kx][ky]; else cout <<"▂"; gotoxy2(kx,ky);
now[1][0]=kx; now[1][1]=ky;
}
if ((ch=='0' || ch==' ')&& b2[kx][ky]<=1){
if (b2[kx][ky]==1){b2[kx][ky]=2; a2[kx][ky]="◎"; c2[kx][ky]=4;}
if (b2[kx][ky]==0){b2[kx][ky]=4; a2[kx][ky]=" ";}
gotoxy2(kx,ky); color(c2[kx][ky]); cout <<a2[kx][ky];
f=0;
check2(kx,ky);
color (7); gotoxy2(12,4); cout <<"("; color(6); cout <<ky; color(7); cout <<","; color(2); cout <<kx;color(7); cout<<") ";
if (b2[kx][ky]==2) move1();
}
if (ch=='8' || ch=='g')
{
if(cjzt=1023577928566)
{
for (int i=1; i<=10; i++) for (int j=1; j<=10; j++)
if (b2[i][j]==1){
gotoxy2(i,j);
color(10);
printf("Ω");
}
}
char ccc=getch();
for (; ccc!='8' && ccc!='g'; ccc=getch());
for (int i=1; i<=10; i++)for (int j=1; j<=10; j++){
gotoxy2(i,j);
color(c2[i][j]);
cout <<a2[i][j];
}
gotoxy2(kx,ky); color(11); if (a2[kx][ky]!=" ")cout <<a2[kx][ky]; else cout <<"▂"; gotoxy2(kx,ky);
}
if (ch=='4' || ch=='q') return(0);
}
return(1);
}
int ok(int x,int y){
int nnn=0;
if (b1[x][y]==2 || b1[x][y]==4 || b1[x][y]==5) return(0);
for (int i=0; i<=7; i++){
if (b1[x+fx[i][0]][y+fx[i][1]]==2) nnn++;
if (b1[x+fx[i][0]][y+fx[i][1]]==5) return(0);
}
if (nnn>1) return(0);
return(1);
}
void check1(int x,int y) {
int k=0,kx,ky,f=1;
for (int i=0; i<=3; i++){
if (b1[x+fx[i][0]][y+fx[i][1]]==2) k=i;
if (b1[x+fx[i][0]][y+fx[i][1]]==1) f=0;
}
for (kx=x,ky=y; b1[kx][ky]==2; kx+=fx[k][0],ky+=fx[k][1]);
if (b1[kx][ky]==1) f=0;
if (f){
int w=0;
color(12);
for (kx=x,ky=y; b1[kx][ky]==2; kx+=fx[k][0],ky+=fx[k][1]){
gotoxy1(kx,ky);
b1[kx][ky]=5;
a1[kx][ky]="※";
c1[kx][ky]=12;
cout <<"※";
w++;
}
for (kx=x+fx[(k+2)%4][0],ky=y+fx[(k+2)%4][1]; b1[kx][ky]==2; kx+=fx[(k+2)%4][0],ky+=fx[(k+2)%4][1]){
gotoxy1(kx,ky);
b1[kx][ky]=5;
a1[kx][ky]="※";
c1[kx][ky]=12;
cout <<"※";
w++;
}
if (w>0){
rest[1][w]--;
r1--;
if (rest[1][w]>0) color(14); else color(11);
gotoxy1(5-w,-5);
printf("%d*",rest[1][w]);
}
}
}
void move2(){
if (r1*r2==0) return;
color(13); gotoxy1(14,4); printf("电脑开炮");
color(5); gotoxy2(14,4); printf("玩家开炮");
Sleep(750);
int kx=0,ky=0,over=0;
while (tail>head){
head++;
kx=fd[head][0]; ky=fd[head][1];
if (ok(kx,ky)){over=1; break;}
}
while (!over){
kx=rand()%(10)+1;
ky=rand()%(10)+1;
if (ok(kx,ky)) over=1;
}
if (b1[kx][ky]==1){b1[kx][ky]=2; a1[kx][ky]="◎"; c1[kx][ky]=4;}
if (b1[kx][ky]==0){b1[kx][ky]=4; a1[kx][ky]=" ";}
gotoxy1(kx,ky); color(11); printf("⊕"); Sleep(600);
gotoxy1(kx,ky); color(c1[kx][ky]); cout <<a1[kx][ky];
color (7); gotoxy1(12,4); cout <<"("; color(6); cout <<ky; color(7); cout <<","; color(2); cout <<kx;color(7); cout<<") ";
check1(kx,ky);
if ((b1[kx][ky]==2 || b1[kx][ky]==5)&& r1*r2>0){
int i=rand()%(4);
for (int ii=0; ii<=3; ii++){
int px=kx+fx[i][0],py=ky+fx[i][1];
if (px>0 && px<=10 && py>0 && py<=10){
tail++;
fd[tail][0]=px;
fd[tail][1]=py;
}
i=(i+1)%4;
}
move2();
}
}
void put(){
int k=4;
while (k--){
for (int i=1; i<=4-k; i++){
int f1=0,f2=0;
int dir1,dir2;
dir1=rand()%(2);
dir2=rand()%(2);
while (!f1){
f1=1;
int lx=rand()%(10)+1;
int ly=rand()%(10)+1;
for(int nx=lx-1; nx<=lx+fx[dir1][0]*k+1; nx++)
for (int ny=ly-1; ny<=ly+fx[dir1][1]*k+1; ny++)
if(b1[nx][ny]==1){f1=0; break;}
for (int nx=lx; nx<=lx+fx[dir1][0]*k; nx++)
for (int ny=ly; ny<=ly+fx[dir1][1]*k; ny++)
if (b1[nx][ny]==3){f1=0; break;}
if (f1){
for (int jx=lx,jy=ly; jx<=lx+fx[dir1][0]*k && jy<=ly+fx[dir1][1]*k; jx+=fx[dir1][0],jy+=fx[dir1][1]){
b1[jx][jy]=1;
c1[jx][jy]=15;
color(15);
gotoxy1(jx,jy); printf("□");
}
}
}
while (!f2){
f2=1;
int lx=rand()%(10)+1;
int ly=rand()%(10)+1;
for(int nx=lx-1; nx<=lx+fx[dir2][0]*k+1; nx++)
for (int ny=ly-1; ny<=ly+fx[dir2][1]*k+1; ny++)
if(b2[nx][ny]==1){f2=0; break;}
for (int nx=lx; nx<=lx+fx[dir2][0]*k; nx++)
for (int ny=ly; ny<=ly+fx[dir2][1]*k; ny++)
if (b2[nx][ny]==3){f2=0; break;}
if (f2){
for (int jx=lx,jy=ly; jx<=lx+fx[dir2][0]*k && jy<=ly+fx[dir2][1]*k; jx+=fx[dir2][0],jy+=fx[dir2][1])
b2[jx][jy]=1;
}
}
int a=1;
}
}
}
void reset(){
system("cls");
color(15);gotoxy(18,10); printf("按 0 重排战船; 按任意键开始与电脑对战");
color(9);
gotoxy(0,9 ); printf("玩家海域");
gotoxy(0,22); printf("电脑海域");
for (int i=1; i<=4; i++) rest[1][i]=rest[2][i]=5-i;
for (int i=1; i<=10; i++){
b1[0][i]=b1[i][0]=b2[0][i]=b2[i][0]=3;
b1[11][i]=b1[i][11]=b2[11][i]=b2[i][11]=3;
}
color(8);
for (int i=1; i<=10; i++)for (int j=1; j<=10; j++) c1[i][j]=c2[i][j]=8;
for (int i=1; i<=10; i++)for (int j=1; j<=10; j++){
b1[i][j]=b2[i][j]=0;
a1[i][j]="□"; gotoxy1(i,j); cout <<a1[i][j];
a2[i][j]="□"; gotoxy2(i,j); cout <<a2[i][j];
}
color(14);
gotoxy1(1,-5); printf("%d*□□□□",rest[1][4]);
gotoxy1(2,-5); printf("%d*□□□ ",rest[1][3]);
gotoxy1(3,-5); printf("%d*□□ ",rest[1][2]);
gotoxy1(4,-5); printf("%d*□ ",rest[1][1]);
gotoxy2(4,12); printf(" □*%d",rest[2][1]);
gotoxy2(3,12); printf(" □□*%d",rest[2][2]);
gotoxy2(2,12); printf(" □□□*%d",rest[2][3]);
gotoxy2(1,12); printf("□□□□*%d",rest[2][4]);
color(2); for (int i=1; i<=10; i++){gotoxy1(i,11); cout <<i; gotoxy2(i,11); cout <<i;}
color(6); for (int i=1; i<=10; i++){gotoxy1(11,i); cout <<i; gotoxy2(11,i); cout <<i;}
color(7); gotoxy1(12,4); printf("( , )"); gotoxy2(12,4); printf("( , )");
put();
now[0][0]=now[0][1]=now[1][0]=now[1][1]=1;
r1=r2=10;
char res=getch(); if (res=='0') reset();
}
int main(){
int gameover=1;
cout<<"请输入密码,暂无密码请按“0”"<<endl;
cin>>wdm;
if(wdm==wdmm)
{
cjzt=1023577928566;
cout<<"请稍后 .";
Sleep(100);
system("cls");
cout<<"请稍后 ..";
Sleep(100);
system("cls");
cout<<"请稍后 ...";
Sleep(100);
system("cls");
cout<<"请稍后 ... .";
Sleep(100);
system("cls");
cout<<"请稍后 ... ..";
Sleep(100);
system("cls");
cout<<"请稍后 ... ...";
Sleep(100);
cout<<"请稍后 .";
Sleep(100);
system("cls");
cout<<"请稍后 ..";
Sleep(100);
system("cls");
cout<<"请稍后 ...";
Sleep(100);
system("cls");
cout<<"请稍后 ... .";
Sleep(100);
system("cls");
cout<<"请稍后 ... ..";
Sleep(100);
system("cls");
cout<<"请稍后 ... ...";
system("cls");
}
else
{
cout<<"请稍后 .";
Sleep(100);
system("cls");
cout<<"请稍后 ..";
Sleep(100);
system("cls");
cout<<"请稍后 ...";
Sleep(100);
system("cls");
cout<<"请稍后 ... .";
Sleep(100);
system("cls");
cout<<"请稍后 ... ..";
Sleep(100);
system("cls");
cout<<"请稍后 ... ...";
Sleep(100);
cout<<"请稍后 .";
Sleep(100);
system("cls");
cout<<"请稍后 ..";
Sleep(100);
system("cls");
cout<<"请稍后 ...";
Sleep(100);
system("cls");
cout<<"请稍后 ... .";
Sleep(100);
system("cls");
cout<<"请稍后 ... ..";
Sleep(100);
system("cls");
cout<<"请稍后 ... ...";
system("cls");
cout<<"请获取密码后重试";
return 0;
}
while (gameover){
srand(time(NULL));
reset();
gotoxy(18,10); printf(" ");
int haha=0;
while (r1*r2){
if (!move1()){haha=1; break;} //玩家(haha==1说明中途退出)
move2(); //电脑
}
gotoxy(18,0);
if (haha) printf("怎么中途退出了...\n\n");
else if (r1==0) printf("很遗憾,你输了...\n\n");
else if (r2==0) printf("恭喜你,你赢了!!!\n\n");
printf("按1退出; 按其它键继续\n>>");
if (getch()=='1') gameover=0;
}
}
0
0
0