c语言 扑克 编程,一个扑克编程

这是一篇关于编程逻辑的博客,作者是个编程爱好者,尝试解决一个扑克牌问题:甲乙丙丁分别抽到两张扑克,条件是甲的两张之和为10,乙的两张之差为1,丙的两张之积为24,丁的两张之商为3。作者编写了程序但遇到困难,希望得到编程高手的指导。
摘要由CSDN通过智能技术生成

已结贴√

问题点数:20 回复次数:7

ca56232b3bbedf9a539d07f37fffb99a.gif

3144d8b7615c79d9f638db40d5689d26.gif

a218af6549b45ee526caf607ebff1358.gif

0f8df0e29816ae721419de940fb833d1.gif

一个扑克编程

我只是个编程爱好者,有个关于扑克的编程:有1~9 9张扑克,甲抽到的两张之和是10,乙抽到的两张差是1,丙抽到的两张积是24,丁抽到的两张商是3。我自己编了个程序,可就不知道错哪儿了,希望高手指教!高分送上!

/*逻辑推理_扑克 之二*/

#include

void main()

{

int puke[9]={1,2,3,4,5,6,7,8,9};

int zhizhen_a=0,zhizhen_b=1,T=0,erro=0,i,

bijiao_a=0,bijiao_b=0,bijiao_c=0,bijiao_d=0,

he_a=0,he_b=0,cha_a=0,cha_b=0,ji_a=0,ji_b=0,shang_a=0,shang_b,

baocun_hea,baocun_heb,baocun_chaa,baocun_chab,

baocun_jia,baocun_jib;

while(erro==0&&T==0) /*最外层为总循环*/

{

while(erro==0&&T==0&&bijiao_a==0)

{

if(puke[zhizhen_a]+puke[zhizhen_b]==10&&puke[zhizhen_a]&&puke[zhizhen_b]

&&zhizhen_a!=zhizhen_b)

{

he_a=puke[zhizhen_a];

he_b=puke[zhizhen_b];

baocun_hea=zhizhen_a;

baocun_heb=zhizhen_b;

puke[zhizhen_a]=puke[zhizhen_b]=0;

zhizhen_a=0;

while(puke[zhizhen_a]==0)zhizhen_a++;

zhizhen_b=zhizhen_a+1;

bijiao_a=bijiao_c=bijiao_d=1;

bijiao_b=0;

}

else

{

bijiao_a=0;

bijiao_b=bijiao_c=bijiao_d=1;

zhizhen_b++;

if(zhizhen_b>8)

{

zhizhen_a++;

zhizhen_b=zhizhen_a+1;

if(zhizhen_a>8)erro=1;

}

}

}

while(erro==0&&T==0&&bijiao_b==0)

{

if(puke[zhizhen_b]-puke[zhizhen_a]==1&&puke[zhizhen_a]&&puke[zhizhen_b]

&&zhizhen_a!=zhizhen_b)

{

cha_b=puke[zhizhen_b];

cha_a=puke[zhizhen_a];

baocun_chaa=zhizhen_a;

baocun_chab=zhizhen_b;

puke[zhizhen_a]=puke[zhizhen_b]=0;

zhizhen_a=zhizhen_a+1;

while(puke[zhizhen_a]==0)zhizhen_a++;

zhizhen_b=zhizhen_a+1;

bijiao_a=bijiao_b=bijiao_d=1;

bijiao_c=0;

}

else

{

bijiao_b=0;

bijiao_a=bijiao_c=bijiao_d=1;

zhizhen_b++;

if(zhizhen_b>8)

{

zhizhen_a++;

zhizhen_b=zhizhen_a+1;

if(zhizhen_a>8)

{

puke[baocun_hea]=he_a;

puke[baocun_heb]=he_b;

zhizhen_a=baocun_hea+1;

zhizhen_b=zhizhen_a+1;

bijiao_b=bijiao_c=bijiao_d=1;

bijiao_a=0;

}

}

}

}

while(erro==0&&T==0&&bijiao_c==0)

{

if(puke[zhizhen_a]*puke[zhizhen_b]==24&&puke[zhizhen_a]&&puke[zhizhen_b]

&&zhizhen_a!=zhizhen_b)

{

ji_a=puke[zhizhen_a];

ji_b=puke[zhizhen_b];

baocun_jia=zhizhen_a;

baocun_jib=zhizhen_b;

puke[zhizhen_a]=puke[zhizhen_b]=0;

zhizhen_a=0;

while(puke[zhizhen_a]==0)zhizhen_a++;

zhizhen_b=zhizhen_a+1;

bijiao_a=bijiao_b=bijiao_c=1;

bijiao_d=0;

}

else

{

bijiao_c=0;

bijiao_a=bijiao_b=bijiao_d=1;

zhizhen_b++;

if(zhizhen_b>8)

{

zhizhen_a++;

zhizhen_b=zhizhen_a+1;

if(zhizhen_a>8)

{

puke[baocun_chaa]=cha_a;

puke[baocun_chab]=cha_b;

zhizhen_a=baocun_chaa+1;

zhizhen_b=zhizhen_a+1;

bijiao_a=bijiao_c=bijiao_d=1;

bijiao_b=0;

}

}

}

}

while(erro==0&&T==0&&bijiao_d==0)

{

if(puke[zhizhen_a]&&puke[zhizhen_b]&&puke[zhizhen_b]/puke[zhizhen_a]==3

&&puke[zhizhen_b]%puke[zhizhen_a]==0&&zhizhen_a!=zhizhen_b)

{

shang_a=puke[zhizhen_a];

shang_b=puke[zhizhen_b];

puke[zhizhen_a]=puke[zhizhen_b]=0;

T=1;

}

else

{

bijiao_d=0;

bijiao_a=bijiao_b=bijiao_c=1;

zhizhen_b++;

if(zhizhen_b>8)

{

zhizhen_a++;

zhizhen_b=zhizhen_a+1;

if(zhizhen_a>8)

{

puke[baocun_jia]=ji_a;

puke[baocun_jib]=ji_b;

zhizhen_a=baocun_jia+1;

zhizhen_b=zhizhen_a+1;

bijiao_a=bijiao_b=bijiao_d=1;

bijiao_c=0;

}

}

}

}

}

printf("%d %d %d %d %d %d %d %d\n",he_a,he_b,cha_a,cha_b,ji_a,ji_b,shang_a,shang_b);

}

搜索更多相关主题的帖子:

爱好者 逻辑推理

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值