C语言/C++求五子棋的程序代码和流程图还有模块设计,求求求,三者都要有~~~求大神帮忙。

栏目:资讯发布:2023-11-12浏览:2收藏

C语言/C++求五子棋的程序代码和流程图还有模块设计,求求求,三者都要有~~~求大神帮忙。,第1张

#include <stdioh>

#include <stdlibh>

#include <conioh>

#include <timeh>

#include <windowsh>

#define TEXTS 7

#define CURSOR 48

#define CHESSBOARD 352

#define WHITECHESS 103

#define SELECTEDWHITE 55

#define BLACKCHESS 96

#define SELECTEDBLACK 48

#define qx1_num 27

#define qx2_num 26

typedef struct node

{

int step;

int color;

} NODE;

typedef struct point

{

int x;

int y;

}_POINT;

typedef struct qixing

{

char qx[8];

int value;

}QIXING;

HANDLE hOutput=GetStdHandle(STD_OUTPUT_HANDLE);

_POINT cursor;

int direction[8][2]={{0,-1},{0,1},{-1,0},{1,0},{-1,-1},{1,1},{-1,1},{1,-1}};

QIXING qx1[qx1_num]={{"x1111",200000},{"1x111",200000},{"11x11",200000},{"0x1110",6000},{"01x110",6000},{"101x101",6000},

{"0x111",1100},{"x0111",1100},{"0x1011",1100},{"0x1101",1100},{"01x11",1100},

{"011x1",1100},{"1x011",1100},{"10x11",1100},{"11x01",1100},{"1x101",1100},

{"x011102",250},{"0x110",250},{"01x10",250},{"0x01102",240},{"0x101",240},

{"0x112",20},{"01x12",10},{"011x2",20},{"1x12",10},{"0x10",20},{"0x010",5}};

QIXING qx2[qx2_num]={{"x1111",2000000},{"1x111",2000000},{"11x11",2000000},{"0x1110",24000},{"01x110",24000},{"101x101",24000},

{"0x111",2000},{"x0111",1900},{"0x1011",1900},{"0x1101",2000},{"01x11",2000},

{"011x1",2000},{"1x011",1900},{"10x11",2000},{"1x101",2000},{"x01112",2000},

{"0x110",850},{"01x10",850},{"0x0110",840},{"0x101",840},

{"0x112",125},{"01x12",125},{"011x2",115},{"1x12",115},{"0x10",125},{"0x010",110}};

//------------------------------------------------------------------------------------------------------

void textcolor(int color)

{

SetConsoleTextAttribute(hOutput, color);

}

void gotoxy(int x, int y)

{

COORD coordScreen={0,0};

coordScreenX=x;

coordScreenY=y;

SetConsoleCursorPosition(hOutput,coordScreen);

}

void printnode(NODE chessboard[][15], int x, int y)

{

textcolor(CHESSBOARD);

if(chessboard[x][y]step==0)

{

if(x==cursorx&&y==cursory)

textcolor(CURSOR);

switch(x)

{

case 0:

if(y==0)printf("┏");

else if(y==14)printf("┓");

else printf("┳");

break;

case 3:

if(y==0)printf("┣");

else if(y==3||y==11)printf("╬");

else if(y==14)printf("┫");

else printf("╋");

break;

case 7:

if(y==0)printf("┣");

else if(y==7)printf("╬");

else if(y==14)printf("┫");

else printf("╋");

break;

case 11:

if(y==0)printf("┣");

else if(y==3||y==11)printf("╬");

else if(y==14)printf("┫");

else printf("╋");

break;

case 14:

if(y==0)printf("┗");

else if(y==14)printf("┛");

else printf("┻");

break;

default:

if(y==0)printf("┣");

else if(y==14)printf("┫");

else printf("╋");

}

}

else if(chessboard[x][y]color==0)

{

if(x==cursorx&&y==cursory)

textcolor(SELECTEDWHITE);

else textcolor(WHITECHESS);

printf("●");

}

else

{

if(x==cursorx&&y==cursory)

textcolor(SELECTEDBLACK);

else textcolor(BLACKCHESS);

printf("●");

}

}

void printchessboard(NODE chessboard[][15])

{

int i,j;

char letter[]={" A B C D E F G H I J K L M N O\n"};

for(i=0;i<15;i++)

{

textcolor(TEXTS);

printf("%2d",15-i);

for(j=0;j<15;j++)

printnode(chessboard,i,j);

textcolor(TEXTS);

printf("\n");

}

textcolor(TEXTS);

printf("%s",letter);

printf("移动:方向键 下棋:ENTER 悔棋:U 退出:F12");

}

void renew(NODE chessboard[][15],int x,int y)

{

COORD coordScreen;

CONSOLE_SCREEN_BUFFER_INFO csbi;

if(x<0||x>14||y<0||y>14)

return;

if(!GetConsoleScreenBufferInfo(hOutput,&csbi))

return;

coordScreen=csbidwCursorPosition;

gotoxy((y-1)2+4,x+1);

printnode(chessboard,x,y);

SetConsoleCursorPosition(hOutput,coordScreen);

}

void showmenu()

{

textcolor(TEXTS);

system("cls");

printf("1人机对战\n2双人对战\n3退出\n\n请选择[1~3]:");

}

void showsubmenu()

{

textcolor(TEXTS);

system("cls");

printf("1你先手\n2电脑先手\n3返回上级菜单\n\n请选择[1~3]:");

}

int getchoose(int min, int max)

{

int choose;

do

{

choose=getch()-48;

}while(choose<min||choose>max);

printf("%d",choose);

return choose;

}

//-------------------------------------------------------------------------------------------------

bool quit;

bool regret;

bool getmove(NODE chessboard[][15])

{

char c;

for(;;)

{

c=getch();

if(c==-32)

switch(getch())

{

case 72:

cursorx--;

if(cursorx<0)cursorx=0;

renew(chessboard,cursorx+1,cursory);

renew(chessboard,cursorx,cursory);

break;

case 80:

cursorx++;

if(cursorx>14)

cursorx=14;

renew(chessboard,cursorx-1,cursory);

renew(chessboard,cursorx,cursory);

break;

case 75:

cursory--;

if(cursory<0)cursory=0;

renew(chessboard,cursorx,cursory+1);

renew(chessboard,cursorx,cursory);

break;

case 77:

cursory++;

if(cursory>14)cursory=14;

renew(chessboard,cursorx,cursory-1);

renew(chessboard,cursorx,cursory);

break;

case 134:

quit=true;

return true;

}

else if(c==13&&chessboard[cursorx][cursory]step==0)

return true;

else if(c=='U'||c=='u')

{

regret=true;

return true;

}

}

}

void beback(NODE chessboard[][15], int step)

{

int i,j,tempx,tempy;

if(step==1)return;

if(step>2)

{

for(i=0;i<15;i++)

for(j=0;j<15;j++)

{

if(chessboard[i][j]step==step-1)

{

chessboard[i][j]step=0;

renew(chessboard,i,j);

}

else if(chessboard[i][j]step==step-2)

{

chessboard[i][j]step=0;

tempx=cursorx;

tempy=cursory;

cursorx=i;

cursory=j;

renew(chessboard,i,j);

renew(chessboard,tempx,tempy);

}

}

}

else if(step==2)

{

for(i=0;i<15;i++)

for(j=0;j<15;j++)

if(chessboard[i][j]step==step-1)

{

chessboard[i][j]step=0;

renew(chessboard,i,j);

}

tempx=cursorx;

tempy=cursory;

cursorx=7;

cursory=7;

renew(chessboard,i,j);

renew(chessboard,tempx,tempy);

}

}

//-----------------------------------------------------------------------------------------

bool inside(int x,int y)

{

if(x<0||x>14||y<0||y>14)return false;

return true;

}

int line(NODE chessboard[][15],int dirt,int x,int y,int color)

{

int i;

for(i=0;chessboard[x+direction[dirt][0]][y+direction[dirt][1]]step>0&&

chessboard[x+direction[dirt][0]][y+direction[dirt][1]]color==color;i++)

{

x=x+direction[dirt][0];

y=y+direction[dirt][1];

if(!inside(x,y))return i;

}

return i;

}

bool win(NODE chessboard[][15],int x,int y,int color)

{

if(line(chessboard,0,x,y,color)+line(chessboard,1,x,y,color)>3)

return true;

if(line(chessboard,2,x,y,color)+line(chessboard,3,x,y,color)>3)

return true;

if(line(chessboard,4,x,y,color)+line(chessboard,5,x,y,color)>3)

return true;

if(line(chessboard,6,x,y,color)+line(chessboard,7,x,y,color)>3)

return true;

return false;

}

//----------------------------------------------------------------------------------------------

int attacktrend,defenttrend;

bool macth1(NODE chessboard[][15],int x,int y,int dirt,int kind,int color)

{

int k;

char c;

char p;

p=strchr(qx1[kind]qx,'x');

for(k=0;k<=p-qx1[kind]qx;k++)

{

x-=direction[dirt][0];

y-=direction[dirt][1];

}

for(k=0;(unsigned)k<strlen(qx1[kind]qx);k++)

{

x+=direction[dirt][0];

y+=direction[dirt][1];

if(!inside(x,y))return(false);

if(chessboard[x][y]step>0&&chessboard[x][y]color==color)c='2';

else if(chessboard[x][y]step>0)c='1';

else c='0';

if(c=='0'&&qx1[kind]qx[k]=='x')continue;

if(c!=qx1[kind]qx[k])return(false);

}

return true;

}

int value_qx1(NODE chessboard[][15],int x,int y,int dirt, int color)

{

int i;

for(i=0;i<qx1_num;i++)

if(macth1(chessboard,x,y,dirt,i,color))

return qx1[i]value;

return 0;

}

bool macth2(NODE chessboard[][15],int x,int y,int dirt, int kind,int color)

{

int k;

char c;

char p;

p=strchr(qx2[kind]qx,'x');

for(k=0;k<=p-qx2[kind]qx;k++)

{

x-=direction[dirt][0];

y-=direction[dirt][1];

}

for(k=0;(unsigned)k<strlen(qx2[kind]qx);k++)

{

x+=direction[dirt][0];

y+=direction[dirt][1];

if(!inside(x,y))return false;

if(chessboard[x][y]step>0&&chessboard[x][y]color==color)c='2';

else if(chessboard[x][y]step>0)c='1';

else c='0';

if(c=='0'&&qx2[kind]qx[k]=='x')continue;

if(c!=qx2[kind]qx[k])return(false);

}

return true;

}

int value_qx2(NODE chessboard[][15],int x,int y,int dirt, int color)

{

int i;

for(i=0;i<qx2_num;i++)

if(macth2(chessboard,x,y,dirt,i,color))

return qx2[i]value;

return 0;

}

void AI(NODE chessboard[][15], int x,int y,int color)

{

int max=0;

int maxi,maxj;

int i,j,k;

int probability=1;

int value[15][15]={0};

int valueattack[15][15]={{0}};

int valuedefent[15][15]={{0}};

for(i=0;i<15;i++)

for(j=0;j<15;j++)

{

if(chessboard[i][j]step>0)continue;

for(k=0;k<8;k++)

valuedefent[i][j]+=value_qx1(chessboard,i,j,k,color);

if(maxi<valuedefent[i][j])

maxi=valuedefent[i][j];

}

for(i=0;i<15;i++)

for(j=0;j<15;j++)

{

if(chessboard[i][j]step>0)continue;

for(k=0;k<8;k++)

valueattack[i][j]+=value_qx2(chessboard,i,j,k,color);

if(maxj<valuedefent[i][j])

maxj=valuedefent[i][j];

}

if(rand()%(maxi+maxj+1)>maxi)

{

attacktrend=1;

defenttrend=1;

}

else

{

attacktrend=1;

defenttrend=2;

}

for(i=0;i<15;i++)

for(j=0;j<15;j++)

{

value[i][j]=valuedefent[i][j]defenttrend+valueattack[i][j]attacktrend;

if(max<value[i][j])

{

max=value[i][j];

maxi=i;

maxj=j;

probability=1;

}

else if(max==value[i][j])

{

if(rand()%(probability+1)<probability)

probability++;

else

{

probability=1;

max=value[i][j];

maxi=i;

maxj=j;

}

}

}

x=maxi;

y=maxj;

}

//-------------------------------------------------------------------------------------------------

bool vshuman;

void Vs(bool human)

{

int i,j;

int color=1;

int lastx,lasty;

int computer;

NODE chessboard[15][15]={{0,0}};

if(!human)

{

showsubmenu();

switch(getchoose(1,3))

{

case 1:

computer=0;

attacktrend=1;

defenttrend=1;

break;

case 2:

computer=1;

attacktrend=1;

defenttrend=2;

break;

case 3:return;

}

}

for(i=0;i<15;i++)

for(j=0;j<15;j++)

chessboard[i][j]step=0;

cursorx=7;

cursory=7;

quit=false;

system("cls");

printf("\n");

printchessboard(chessboard);

for(i=1;i<=225;)

{

gotoxy(0,0);

textcolor(TEXTS);

printf(" 第%03d手, ",i);

if(color==1)printf("黑棋下");

else printf("白棋下");

regret=false;

if(i>1)

{

if(color!=computer||human)getmove(chessboard);

else

{

lastx=cursorx;

lasty=cursory;

AI(chessboard,&cursorx,&cursory,color);

renew(chessboard,lastx,lasty);

}

}

if(quit)return;

if(regret)

{

beback(chessboard,i);

if(i>2)i-=2;

else if(i==2)

{

i=1; color=(color+1)%2;

}

}

else

{

chessboard[cursorx][cursory]step=i++;

chessboard[cursorx][cursory]color=color;

renew(chessboard,cursorx,cursory);

color=(color+1)%2;

}

if(win(chessboard,cursorx,cursory,(color+1)%2)&&!regret)

{

textcolor(TEXTS);

gotoxy(0,0);

printf(" ");

gotoxy(0,0);

if(color==1)printf(" 白棋赢了!");

else printf(" 黑棋赢了!");

getch();

return;

}

}

gotoxy(0,0);

printf(" ");

gotoxy(0,0);

printf(" 平局!");

}

int main()

{

srand((unsigned)time(NULL));

for(;;)

{

showmenu();

switch(getchoose(1,3))

{

case 1:Vs(false);break;

case 2:Vs(true);break;

case 3:printf("\n");return 0;

}

}

return 0;

}

#include <iostream>

#include <ctime>

using namespace std;

//全局变量,一副牌

//

int g_cards[54] = {

0, 1, 2, 3, // 3

10, 11, 12, 13, // 4

20, 21, 22, 23, // 5

30, 31, 32, 33, // 6

40, 41, 42, 43, // 7

50, 51, 52, 53, // 8

60, 61, 62, 63, // 9

70, 71, 72, 73, // 10

80, 81, 82, 83, // J

90, 91, 92, 93, // Q

100, 101, 102, 103, // K

110, 111, 112, 113, // A

120, 121, 122, 123, // 2

130, //小王

140 //大王

};

void xipai() //洗牌全局函数

{

srand( time(NULL) ); //设置种子

for(int i=0; i<54 ; i++)

{

int position = rand()%54;

int temp = g_cards[i]; //与牌的下标进行互换

g_cards[i] = g_cards[position];

g_cards[position] = temp;

}

}

void showCards() //显示全局函数

{

for(int i=0; i<54 ; i++)

{

if( g_cards[i] != 130 && g_cards[i] !=140 )

{

switch(g_cards[i]%10)

{

case 0:

cout<<"黑桃:";

break;

case 1:

cout<<"红桃:";

break;

case 2:

cout<<"梅花:";

break;

case 3:

cout<<"方片:";

break;

}

}

switch(g_cards[i]/10)

{

case 0:

cout<<"3:"<<endl;

break;

case 1:

cout<<"4:"<<endl;

break;

case 2:

cout<<"5:"<<endl;

break;

case 3:

cout<<"6:"<<endl;

break;

case 4:

cout<<"7:"<<endl;

break;

case 5:

cout<<"8:"<<endl;

break;

case 6:

cout<<"9:"<<endl;

break;

case 7:

cout<<"10:"<<endl;

break;

case 8:

cout<<"J:"<<endl;

break;

case 9:

cout<<"Q:"<<endl;

break;

case 10:

cout<<"K:"<<endl;

break;

case 11:

cout<<"A:"<<endl;

break;

case 12:

cout<<"2:"<<endl;

break;

case 13:

cout<<"小王:"<<endl;

break;

case 14:

cout<<"大王:"<<endl;

break;

}

}

}

//

struct CARDMESSAGE

{

//牌型, 牌的信息

int cardType; //牌型 0 单牌 1 双牌 2 三带一/二 3 四带一/二 4 顺子 5 连对 6 飞机 7 炸弹

int size; //牌的张数

int value; //牌值

int num; //连对或者飞机的顺数, -1为无限制

bool isLord; //是否是地主出的牌

void show()

{

switch(cardType)

{

case 0:

cout<<"单张:"<<endl;

break;

case 1:

cout<<"两张:"<<endl;

break;

case 2:

{

if(size==4)

cout<<"三带一:"<<endl;

else

cout<<"三带二:"<<endl;

}

case 3:

{

if(size == 5)

cout<<"四带一"<<endl;

else

cout<<"四带二"<<endl;

}

case 4:

{

cout<<"顺子"<<endl;

}

case 5:

{

cout<<"连对"<<endl;

}

case 6:

{

cout<<"飞机"<<endl;

}

case 7:

{

cout<<"炸弹"<<endl;

}

}

break;

}

switch(value%10)

{

case 0:

cout<<"黑桃:"<<endl;

break;

case 1:

cout<<"红桃:"<<endl;

break;

case 2:

cout<<"梅花:"<<endl;

break;

case 3:

cout<<"方片:"<<endl;

break;

}

switch(value/10)

{

case 0:

cout<<"3:"<<endl;

break;

case 1:

cout<<"4:"<<endl;

break;

case 2:

cout<<"5:"<<endl;

break;

case 3:

cout<<"6:"<<endl;

break;

case 4:

cout<<"7:"<<endl;

break;

case 5:

cout<<"8:"<<endl;

break;

case 6:

cout<<"9:"<<endl;

break;

case 7:

cout<<"10:"<<endl;

break;

case 8:

cout<<"J:"<<endl;

break;

case 9:

cout<<"Q:"<<endl;

break;

case 10:

cout<<"K:"<<endl;

break;

case 11:

cout<<"A:"<<endl;

break;

case 12:

cout<<"2:"<<endl;

break;

case 13:

cout<<"小王:"<<endl;

break;

case 14:

cout<<"大王:"<<endl;

break;

}

}

};

//

class Ccard

{

public:

int cardArray[20]; //保存所有牌的信息

int cardNum; //有效牌的张数

public:

Ccard();

~Ccard();

void sortCard();

void getCards(); //获得多张牌

void getOneCard(int card , int index ); //在发牌过程中获得一张牌

void show();

};

void Ccard::getOneCard(int card , int index )

{

cardArray[index] = card;

}

void Ccard::show()

{

for(int i=0; i<cardNum ; i++)

{

if( cardArray[i] != 130 && cardArray[i] !=140 )

{

switch(cardArray[i]%10)

{

case 0:

cout<<"黑桃:";

break;

case 1:

cout<<"红桃:";

break;

case 2:

cout<<"梅花:";

break;

case 3:

cout<<"方片:";

break;

}

}

switch(cardArray[i]/10)

{

case 0:

cout<<"3:" ;

break;

case 1:

cout<<"4:" ;

break;

case 2:

cout<<"5:" ;

break;

case 3:

cout<<"6:" ;

break;

case 4:

cout<<"7:" ;

break;

case 5:

cout<<"8:" ;

break;

case 6:

cout<<"9:" ;

break;

case 7:

cout<<"10:" ;

break;

case 8:

cout<<"J:" ;

break;

case 9:

cout<<"Q:" ;

break;

case 10:

cout<<"K:" ;

break;

case 11:

cout<<"A:" ;

break;

case 12:

cout<<"2:" ;

break;

case 13:

cout<<"小王:" ;

break;

case 14:

cout<<"大王:" ;

break;

}

}

}

Ccard::Ccard()

{

for( int j = 0; j<20 ;j++)

{

cardArray[j] = -1;

}

}

Ccard::~Ccard()

{

}

void Ccard::getCards()

{

for(int i=0; i<17 ; i++)

{

cardArray[i] = g_cards[i];

}

cardNum = 17;

}

void Ccard::sortCard()

{

for( int j = 0; j<cardNum-1 ;j++)

{

for(int i = 0; i<cardNum-1-j ;i++)

{

if( cardArray[i]<cardArray[i+1] )

{

int temp ;

temp = cardArray[i];

cardArray[i] = cardArray[i+1];

cardArray[i+1] = temp;

}

}

}

}

//

void fapai(Ccard& player1,Ccard& player2,Ccard& player3)

{

for(int i=0;i<17;i++)

{

player1getOneCard( g_cards[i3] , i);

player2getOneCard( g_cards[i3 + 1] , i);

player3getOneCard( g_cards[i3 + 2] , i);

player1cardNum = 17;

player2cardNum = 17;

player3cardNum = 17;

}

}

int main()

{

Ccard a;

Ccard b;

Ccard c;

xipai(); //第一步 洗牌

fapai(a,b,c); //第二步 发牌

//第三步 发地主牌

ashow();

cout<<""<<endl;

bshow();

cout<<""<<endl;

cshow();

return 0;

}

以前学的时候写的不知道有没有用

C语言中常用的选择结构主要有以下两种:

(1) if else:引入关键字:if  else  else if

if (bool值)   // 如果bool值为真,则执行代码段1,否则执行代码段2

{

代码段1

}

else

{

代码段2

}

if (bool值1)    // 如果bool值1为真,则执行代码段1,否则判断bool值2是否为真

{

代码段1

}

else if (bool值2)  // 若bool值2为真则执行代码段2,否则直接执行代码段3

{          // 开头的if和结尾的else都只能有一个,但是中间的else if可以有好多个

代码段2

}

else

{

代码段3

}

(2) switch case:引入关键字:switch  case  break  default

switch (变量)       // 执行到这一句时,变量的值是已知的

{             // switch case语句执行时,会用该变量的值依次与各个case后的常数去对比,试图找到第一个匹配项,找到匹配的项目后,

case 常数1:       // 就去执行该case对应的代码段,如果没找到则继续下一个case,直到default

代码段1;        // 如果前面的case都未匹配,则default匹配。

break;

case 常数2:  

代码段2;

break;

……

default:

代码段n;

break;

}

注:第一,case中必须是常数,而且必须是整形;

第二,一般来说,每个case中代码段后都必须有一个break;

第三,case之后一般都会有default,虽然语法上允许没有default,但是建议写代码时一定要写;

(3) if else和switch case的区别:if else适合对比条件较复杂,但是分支比较少的情况,switch case适合那种对比条件简单,但是分支较多的情况;

通常的做法是:在适合使用switch case的情况下会优先使用switch case,如果不适合则使用if else;

http://wwwcnblogscom/ARM-kang/p/6442949html

硬要说有第三种的话

只有while()

{

}

#include<stdioh>

int main(void)

{

int a,b,c,n;

printf("请输入币值:");

scanf("%d",&n);

printf("\n方案如下\n---------------\n 一元 两元 五元\n");

for(a=1;a<=n-7;a++)

{

for(b=1;b<(n-a)/2+1;b++)

{

for(c=1;c<(n-a-2b)/5+1;c++)

{

if((a+2b+5c)==n)

printf("\n---%d---%d---%d---",a,b,c);

}

}

}

return 0;

}

如果希望换出的零钱越来越少,我给你个思路吧,就是5元的最多,其次两元,最后是一元;那么就先确定五元的币数,然后两元,最后循环得出一元币数;

很简单,实际就是一个递归调用,不断调用hanoi,实质就是把n-1个圆盘从A移至B,将第n个圆盘从A移至C,再将n-1个圆盘从B移动到C,当n不等于1时,就不断迭代这个循环,直到n=1:

希望你能明白:

#include<stdioh>  

void move(char x,char y)  

{   

printf("%c-->%c\n",x,y); 

}  

void hanoi(int n,char one ,char two,char three)

{  

 if(n==1) move(one,three);  

 else   

  {   

      hanoi(n-1,one,three,two);  

     move(one,three);   

      hanoi(n-1,two,one,three);   

   }   

}  

 

main()   

{   

     int m;   

     printf("input the number of disks:");   

     scanf("%d",&m);   

     printf("the step to moving %3d diskes:\n",m);   

     hanoi(m,'A','B','C');   

}

楼主你好!

根据你的要求,代码实现如下:

#include "conioh"

#include<stdioh>

#include<stringh>

#include<stdlibh>

int main(){

char a[]="123456";      // 密码

char ch;

char st[20]; 

int i,k=1;    //k用于统计输入密码的次数

A:printf("请输入密码:");

i=0;

ch=getch();      /  getch()函数从键盘接收字符,不在屏幕上显示  /

while(ch!=13)   /  13为换行字符ASCII码 ,键盘输入为回车键 /

{st[i]=ch;

  putchar('');

  ch=getch();

  i++;

}

     st[i]= '\0';

     if(strcmp(a,st)==0)printf("\n您好,我的主人!\n");

     else

 {

  printf("\n离我远点!\n");

  k++;

  if(k>3)exit(0);

  goto A;

     }

}

希望我的回答对你有帮助!望采纳!

C语言/C++求五子棋的程序代码和流程图还有模块设计,求求求,三者都要有~~~求大神帮忙。

#include <stdioh>#include <stdlibh>#include <conioh>#include <timeh>#include <windowsh>#define TEXTS 7#define CURSOR 48#d...
点击下载
热门文章
    确认删除?
    回到顶部