小春网

 找回密码
 注册账号
查看: 1167|回复: 10
收起左侧

[IT 交流] C语言猜数游戏

[复制链接]
发表于 2013-11-17 21:28:47 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册账号

x
本帖最后由 憨吃迷糊睡 于 2013-11-17 21:45 编辑

由电脑自动生成随机的3位数字,
由两位玩家轮番进行猜测

当数字和位置都正确时,电脑提示A;
当数字正确,位置不正确时,电脑提示B
玩家根据电脑的提示进行进一步猜测,直到有一方成功猜对所有数字和位置为止

迷糊用C语言开发的,支持VC和GCC编译
可以自己开发算法和既存的玩家进行PK
感兴趣的版友可以下载一份代码,迷糊感觉蛮有趣的

https://code.google.com/p/xiaochunnet/downloads/list
guessnum_v1.01.zip

v1.0版的Player1和Player2都是使用随机推测的,以后会不断更新新的版本
 楼主| 发表于 2013-11-17 21:32:36 | 显示全部楼层
本帖最后由 憨吃迷糊睡 于 2013-11-17 21:46 编辑

程序输出示例
=======================================
Computer think of number with unique digits:[295]
-------------------------------------------------------------------------------
A means how many of your digits are in right position.
B means how many of your digits match but in wrong position.
X means error occurs. Please check your program logic.
-------------------------------------------------------------------------------
Player1Guess[260]->[1A0B]
Player2Guess[794]->[1A0B]
Player1Guess[805]->[1A0B]
Player2Guess[153]->[0A1B]
Player1Guess[623]->[0A1B]
Player2Guess[809]->[0A1B]
Player1Guess[421]->[0A1B]
Player2Guess[546]->[0A1B]
Player1Guess[129]->[0A2B]
Player2Guess[394]->[1A0B]
Player1Guess[045]->[1A0B]
Player2Guess[192]->[1A1B]
Player1Guess[410]->[0A0B]
Player2Guess[826]->[0A1B]
Player1Guess[645]->[1A0B]
Player2Guess[931]->[0A1B]
Player1Guess[395]->[2A0B]
Player2Guess[352]->[0A2B]
Player1Guess[107]->[0A0B]
Player2Guess[375]->[1A0B]
Player1Guess[184]->[0A0B]
Player2Guess[758]->[0A1B]
Player1Guess[269]->[1A1B]
Player2Guess[536]->[0A1B]
Player1Guess[106]->[0A0B]
Player2Guess[486]->[0A0B]
Player1Guess[439]->[0A1B]
Player2Guess[417]->[0A0B]
Player1Guess[573]->[0A1B]
Player2Guess[352]->[0A2B]
Player1Guess[814]->[0A0B]
Player2Guess[109]->[0A1B]
Player1Guess[941]->[0A1B]
Player2Guess[642]->[0A1B]
Player1Guess[973]->[0A1B]
Player2Guess[850]->[0A1B]
Player1Guess[648]->[0A0B]
Player2Guess[470]->[0A0B]
Player1Guess[390]->[1A0B]
Player2Guess[345]->[1A0B]
Player1Guess[625]->[1A1B]
Player2Guess[394]->[1A0B]
Player1Guess[604]->[0A0B]
Player2Guess[413]->[0A0B]
Player1Guess[517]->[0A1B]
Player2Guess[502]->[0A2B]
Player1Guess[814]->[0A0B]
Player2Guess[740]->[0A0B]
Player1Guess[329]->[0A2B]
Player2Guess[251]->[1A1B]
Player1Guess[253]->[1A1B]
Player2Guess[526]->[0A2B]
Player1Guess[254]->[1A1B]
Player2Guess[957]->[0A2B]
Player1Guess[806]->[0A0B]
Player2Guess[072]->[0A1B]
Player1Guess[345]->[1A0B]
Player2Guess[382]->[0A1B]
Player1Guess[846]->[0A0B]
Player2Guess[086]->[0A0B]
Player1Guess[746]->[0A0B]
Player2Guess[846]->[0A0B]
Player1Guess[508]->[0A1B]
Player2Guess[294]->[2A0B]
Player1Guess[510]->[0A1B]
Player2Guess[958]->[0A2B]
Player1Guess[594]->[1A1B]
Player2Guess[870]->[0A0B]
Player1Guess[217]->[1A0B]
Player2Guess[473]->[0A0B]
Player1Guess[139]->[0A1B]
Player2Guess[387]->[0A0B]
Player1Guess[912]->[0A2B]
Player2Guess[281]->[1A0B]
Player1Guess[394]->[1A0B]
Player2Guess[618]->[0A0B]
Player1Guess[390]->[1A0B]
Player2Guess[297]->[2A0B]
Player1Guess[169]->[0A1B]
Player2Guess[769]->[0A1B]
Player1Guess[683]->[0A0B]
Player2Guess[839]->[0A1B]
Player1Guess[241]->[1A0B]
Player2Guess[140]->[0A0B]
Player1Guess[971]->[0A1B]
Player2Guess[273]->[1A0B]
Player1Guess[513]->[0A1B]
Player2Guess[326]->[0A1B]
Player1Guess[962]->[0A2B]
Player2Guess[632]->[0A1B]
Player1Guess[389]->[0A1B]
Player2Guess[753]->[0A1B]
Player1Guess[380]->[0A0B]
Player2Guess[853]->[0A1B]
Player1Guess[067]->[0A0B]
Player2Guess[518]->[0A1B]
Player1Guess[684]->[0A0B]
Player2Guess[736]->[0A0B]
Player1Guess[526]->[0A2B]
Player2Guess[130]->[0A0B]
Player1Guess[293]->[2A0B]
Player2Guess[210]->[1A0B]
Player1Guess[269]->[1A1B]
Player2Guess[138]->[0A0B]
Player1Guess[573]->[0A1B]
Player2Guess[193]->[1A0B]
Player1Guess[915]->[1A1B]
Player2Guess[917]->[0A1B]
Player1Guess[361]->[0A0B]
Player2Guess[957]->[0A2B]
Player1Guess[694]->[1A0B]
Player2Guess[598]->[1A1B]
Player1Guess[539]->[0A2B]
Player2Guess[854]->[0A1B]
Player1Guess[045]->[1A0B]
Player2Guess[765]->[1A0B]
Player1Guess[946]->[0A1B]
Player2Guess[196]->[1A0B]
Player1Guess[712]->[0A1B]
Player2Guess[652]->[0A2B]
Player1Guess[403]->[0A0B]
Player2Guess[984]->[0A1B]
Player1Guess[327]->[0A1B]
Player2Guess[306]->[0A0B]
Player1Guess[459]->[0A2B]
Player2Guess[046]->[0A0B]
Player1Guess[692]->[1A1B]
Player2Guess[238]->[1A0B]
Player1Guess[906]->[0A1B]
Player2Guess[520]->[0A2B]
Player1Guess[863]->[0A0B]
Player2Guess[485]->[1A0B]
Player1Guess[936]->[0A1B]
Player2Guess[901]->[0A1B]
Player1Guess[418]->[0A0B]
Player2Guess[104]->[0A0B]
Player1Guess[741]->[0A0B]
Player2Guess[168]->[0A0B]
Player1Guess[987]->[0A1B]
Player2Guess[295]->[3A0B]
Guess 70 Times. Player2 WIN!
=======================================



回复

使用道具 举报

发表于 2013-11-17 23:14:41 | 显示全部楼层
.,,,.,.,.,.,.,.
回复

使用道具 举报

发表于 2013-11-26 14:08:25 | 显示全部楼层
这个帮过一个商学专攻的朋友的计算机课程结业论文的程序设计~~哈哈~
回复

使用道具 举报

发表于 2013-11-26 14:09:18 | 显示全部楼层
上学时候玩文曲星很爱玩这个~然后在文曲星上的QBasic上也原样写了一个~~
回复

使用道具 举报

 楼主| 发表于 2013-11-26 22:53:52 | 显示全部楼层
荣耀与梦想 发表于 2013-11-26 14:09
上学时候玩文曲星很爱玩这个~然后在文曲星上的QBasic上也原样写了一个~~

荣耀也写一个player吧,大家PK一下
回复

使用道具 举报

发表于 2013-12-3 14:37:13 | 显示全部楼层
我也是学习C的哦
回复

使用道具 举报

 楼主| 发表于 2013-12-8 09:55:14 | 显示全部楼层

写个Player,PK一下
回复

使用道具 举报

头像被屏蔽
发表于 2014-1-9 10:47:26 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复

使用道具 举报

发表于 2014-1-13 01:02:20 | 显示全部楼层
人品不错~~~
111.PNG
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册账号

本版积分规则

小春网
常务客服微信
微信订阅号
手机客户端
扫一扫,查看更方便! 快速回复 返回顶部 返回列表