| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 639 人关注过本帖
标题:一个扑克编程
取消只看楼主 加入收藏
chfplang
Rank: 1
来 自:河北
等 级:新手上路
帖 子:10
专家分:2
注 册:2009-7-23
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:1 
一个扑克编程
我只是个编程爱好者,有个关于扑克的编程:有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);
}
搜索更多相关主题的帖子: 爱好者 逻辑推理 
2011-08-08 00:49
chfplang
Rank: 1
来 自:河北
等 级:新手上路
帖 子:10
专家分:2
注 册:2009-7-23
收藏
得分:0 
回复 3楼 韩54521风
说实话,你给的程序也不是我想要的。我只是想让人帮我找出我程序中的错误,不过你这种思路比我的要简洁的多,所以给你了。谢谢你!
2011-08-11 01:43
快速回复:一个扑克编程
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.023245 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved