一人3张扑克牌比大小思路2.docx

上传人:b****3 文档编号:3690098 上传时间:2022-11-24 格式:DOCX 页数:22 大小:17.40KB
下载 相关 举报
一人3张扑克牌比大小思路2.docx_第1页
第1页 / 共22页
一人3张扑克牌比大小思路2.docx_第2页
第2页 / 共22页
一人3张扑克牌比大小思路2.docx_第3页
第3页 / 共22页
一人3张扑克牌比大小思路2.docx_第4页
第4页 / 共22页
一人3张扑克牌比大小思路2.docx_第5页
第5页 / 共22页
点击查看更多>>
下载资源
资源描述

一人3张扑克牌比大小思路2.docx

《一人3张扑克牌比大小思路2.docx》由会员分享,可在线阅读,更多相关《一人3张扑克牌比大小思路2.docx(22页珍藏版)》请在冰豆网上搜索。

一人3张扑克牌比大小思路2.docx

一人3张扑克牌比大小思路2

一人3张扑克牌比大小思路2

#include

#defineboolint

#definetrue1

#definefalse0

chara[3][4],b[3][4];

voidwrite();

boolisError();

voidsort();

voidwinner();

voidread();

voidmain()

{

write();

if(!

isError())

{

printf("InputError!

\n");

return;

}

sort();

winner();

read();

}

voidwrite()

{

printf("请输入A的扑克牌,样式如下:

S3H4CA,然后按下回车键\n");

scanf("%s%s%s",a[0],a[1],a[2]);

printf("请输入B的扑克牌,样式如下:

S3H4CA,然后按下回车键\n");

scanf("%s%s%s",b[0],b[1],b[2]);

}

boolisError()

{

inti,k,j,flag;

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

{

if(a[i][0]!

='H'&&a[i][0]!

='S'&&a[i][0]!

='D'&&a[i][0]!

='C')

gotolabel1;

if(a[i][1]>='1'&&a[i][1]<='9')

{

if(a[i][1]!

='1'&&a[i][2]!

=0)

gotolabel1;

if(a[i][1]=='1')

if(a[i][2]=='0'&&a[i][3]==0)

;

else

gotolabel1;

}else

if((a[i][1]=='J'||a[i][1]=='Q'||a[i][1]=='K'||a[i][1]=='A')&&a[i][2]==0)

{

;

}

else

gotolabel1;

}

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

for(k=i+1,flag=0;k<3;k++)

{

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

{

if(a[i][j]!

=a[k][j])

{

flag=1;

break;

}

}

if(flag==0)

gotolabel1;

}

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

{

if(b[i][0]!

='H'&&b[i][0]!

='S'&&b[i][0]!

='D'&&b[i][0]!

='C')

gotolabel1;

if(b[i][1]>='1'&&b[i][1]<='9')

{

if(b[i][1]!

='1'&&b[i][2]!

=0)

gotolabel1;

if(b[i][1]=='1')

if(b[i][2]=='0'&&b[i][3]==0)

;

else

gotolabel1;

}else

if((b[i][1]=='J'||b[i][1]=='Q'||b[i][1]=='K'||b[i][1]=='A')&&b[i][2]==0)

{

;

}

else

gotolabel1;

}

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

for(k=i+1,flag=0;k<3;k++)

{

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

{

if(b[i][j]!

=b[k][j])

{

flag=1;

break;

}

}

if(flag==0)

gotolabel1;

}

returntrue;

label1:

returnfalse;

}

voidsort()

{

intm,n,x;

chartemp;

for(m=0;m<2;m++)

{

for(n=m+1;n<3;n++)

{

if(a[m][0]!

='H')

{

if(a[n][0]=='H')

{

for(x=0;x<4;x++)

{

temp=a[n][x];

a[n][x]=a[m][x];

a[m][x]=temp;

}

gotolabel2;

}else

{

if(a[m][0]

{

for(x=0;x<4;x++)

{

temp=a[n][x];

a[n][x]=a[m][x];

a[m][x]=temp;

}

gotolabel2;

}elseif(a[m][0]==a[n][0])

{

if(a[m][1]=='K')

{

if(a[n][1]=='A')

{

for(x=0;x<4;x++)

{

temp=a[n][x];

a[n][x]=a[m][x];

a[m][x]=temp;

}

gotolabel2;

}

}

if(a[m][1]=='Q')

{

if(a[n][1]=='A'||a[n][1]=='K')

{

for(x=0;x<4;x++)

{

temp=a[n][x];

a[n][x]=a[m][x];

a[m][x]=temp;

}

gotolabel2;

}

}

if(a[m][1]=='J')

{

if(a[n][1]=='A'||a[n][1]=='K'||a[n][1]=='Q')

{

for(x=0;x<4;x++)

{

temp=a[n][x];

a[n][x]=a[m][x];

a[m][x]=temp;

}

gotolabel2;

}

}

if(a[m][1]=='1')

{

if(a[n][1]=='A'||a[n][1]=='K'||a[n][1]=='Q'||a[n][1]=='J')

{

for(x=0;x<4;x++)

{

temp=a[n][x];

a[n][x]=a[m][x];

a[m][x]=temp;

}

gotolabel2;

}

}

if(a[m][1]>='2'&&a[m][1]<='9')

{

if(a[m][1]

{

for(x=0;x<4;x++)

{

temp=a[n][x];

a[n][x]=a[m][x];

a[m][x]=temp;

}

gotolabel2;

}

}

}

}

}

if(a[n][0]=='H')

{

if(a[m][1]=='K')

{

if(a[n][1]=='A')

{

for(x=0;x<4;x++)

{

temp=a[n][x];

a[n][x]=a[m][x];

a[m][x]=temp;

}

gotolabel2;

}

}

if(a[m][1]=='Q')

{

if(a[n][1]=='A'||a[n][1]=='K')

{

for(x=0;x<4;x++)

{

temp=a[n][x];

a[n][x]=a[m][x];

a[m][x]=temp;

}

gotolabel2;

}

}

if(a[m][1]=='J')

{

if(a[n][1]=='A'||a[n][1]=='K'||a[n][1]=='Q')

{

for(x=0;x<4;x++)

{

temp=a[n][x];

a[n][x]=a[m][x];

a[m][x]=temp;

}

gotolabel2;

}

}

if(a[m][1]=='1')

{

if(a[n][1]=='A'||a[n][1]=='K'||a[n][1]=='Q'||a[n][1]=='J')

{

for(x=0;x<4;x++)

{

temp=a[n][x];

a[n][x]=a[m][x];

a[m][x]=temp;

}

gotolabel2;

}

}

if(a[m][1]>='2'&&a[m][1]<='9')

{

if(a[m][1]

{

for(x=0;x<4;x++)

{

temp=a[n][x];

a[n][x]=a[m][x];

a[m][x]=temp;

}

gotolabel2;

}

}

}

label2:

;

}

}

for(m=0;m<2;m++)

{

for(n=m+1;n<3;n++)

{

if(b[m][0]!

='H')

{

if(b[n][0]=='H')

{

for(x=0;x<4;x++)

{

temp=b[n][x];

b[n][x]=b[m][x];

b[m][x]=temp;

}

gotolabel3;

}else

{

if(b[m][0]

{

for(x=0;x<4;x++)

{

temp=b[n][x];

b[n][x]=b[m][x];

b[m][x]=temp;

}

gotolabel3;

}elseif(b[m][0]==b[n][0])

{

if(b[m][1]=='K')

{

if(b[n][1]=='A')

{

for(x=0;x<4;x++)

{

temp=b[n][x];

b[n][x]=b[m][x];

b[m][x]=temp;

}

gotolabel3;

}

}

if(b[m][1]=='Q')

{

if(b[n][1]=='A'||b[n][1]=='K')

{

for(x=0;x<4;x++)

{

temp=b[n][x];

b[n][x]=b[m][x];

b[m][x]=temp;

}

gotolabel3;

}

}

if(b[m][1]=='J')

{

if(b[n][1]=='A'||b[n][1]=='K'||b[n][1]=='Q')

{

for(x=0;x<4;x++)

{

temp=b[n][x];

b[n][x]=b[m][x];

b[m][x]=temp;

}

gotolabel3;

}

}

if(b[m][1]=='1')

{

if(b[n][1]=='A'||b[n][1]=='K'||b[n][1]=='Q'||b[n][1]=='J')

{

for(x=0;x<4;x++)

{

temp=b[n][x];

b[n][x]=b[m][x];

b[m][x]=temp;

}

gotolabel3;

}

}

if(b[m][1]>='2'&&b[m][1]<='9')

{

if(b[m][1]

{

for(x=0;x<4;x++)

{

temp=b[n][x];

b[n][x]=b[m][x];

b[m][x]=temp;

}

gotolabel3;

}

}

}

}

}

if(b[n][0]=='H')

{

if(b[m][1]=='K')

{

if(b[n][1]=='A')

{

for(x=0;x<4;x++)

{

temp=b[n][x];

b[n][x]=b[m][x];

b[m][x]=temp;

}

gotolabel3;

}

}

if(b[m][1]=='Q')

{

if(b[n][1]=='A'||b[n][1]=='K')

{

for(x=0;x<4;x++)

{

temp=b[n][x];

b[n][x]=b[m][x];

b[m][x]=temp;

}

gotolabel3;

}

}

if(b[m][1]=='J')

{

if(b[n][1]=='A'||b[n][1]=='K'||b[n][1]=='Q')

{

for(x=0;x<4;x++)

{

temp=b[n][x];

b[n][x]=b[m][x];

b[m][x]=temp;

}

gotolabel3;

}

}

if(b[m][1]=='1')

{

if(b[n][1]=='A'||b[n][1]=='K'||b[n][1]=='Q'||b[n][1]=='J')

{

for(x=0;x<4;x++)

{

temp=b[n][x];

b[n][x]=b[m][x];

b[m][x]=temp;

}

gotolabel3;

}

}

if(b[m][1]>='2'&&b[m][1]<='9')

{

if(b[m][1]

{

for(x=0;x<4;x++)

{

temp=b[n][x];

b[n][x]=b[m][x];

b[m][x]=temp;

}

gotolabel3;

}

}

}

label3:

;

}

}

}

voidwinner()

{

inty;

for(y=0;y<3;y++)

{

if(a[y][0]!

='H')

{

if(b[y][0]=='H'||b[y][0]>a[y][0])

{

printf("WinnerisB!

\n");

return;

}

else

if(a[y][0]>b[y][0])

{

printf("WinnerisA!

\n");

return;

}else

{

if(a[y][0]==b[y][0])

{

if(a[y][1]=='1')

{

if(b[y][1]=='J'||b[y][1]=='Q'||b[y][1]=='K'||b[y][1]=='A')

{

printf("WinnerisB!

\n");

return;

}

else

{

if(b[y][1]=='1')

{

continue;

}else

{

printf("WinnerisA!

\n");

return;

}

}

}else

{

if(b[y][1]==a[y][1])

{

continue;

}else

{

if(b[y][1]=='1')

{

if(a[y][1]=='J'||a[y][1]=='Q'||a[y][1]=='K'||a[y][1]=='A')

{

printf("WinnerisA!

\n");

return;

}else

{

printf("WinnerisB!

\n");

return;

}

}else

{

if(b[y][1]!

='J'&&b[y][1]!

='Q'&&b[y][1]!

='K'&&b[y][1]!

='A')

{

if(a[y][1]=='J'||a[y][1]=='Q'||a[y][1]=='K'||a[y][1]=='A'||a[y][1]>b[y][1])

{

printf("WinnerisA!

\n");

return;

}

else

{

printf("WinnerisB!

\n");

return;

}

}

else

{

if(a[y][1]!

='J'&&a[y][1]!

='Q'&&a[y][1]!

='K'&&a[y][1]!

='A')

{

printf("WinnerisB!

\n");

return;

}

else

{

if(a[y][1]=='A')

{

printf("WinnerisA!

\n");

return;

}else

{

if(a[y][1]=='K'&&(b[y][1]=='J'||b[y][1]=='Q'))

{

printf("WinnerisA!

\n");

return;

}else

{

if(a[y][1]=='Q'&&b[y][1]=='J')

{

printf("WinnerisA!

\n");

return;

}

}

}

printf("WinnerisB!

\n");

return;

}

}

}

}

}

}else

{

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 外语学习 > 法语学习

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1