| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1034 人关注过本帖
标题:新手求解大神猜数字问题编法
取消只看楼主 加入收藏
hushuncheng
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2016-10-9
结帖率:25%
收藏
已结贴  问题点数:10 回复次数:1 
新手求解大神猜数字问题编法
程序内容:两个人互相猜数字,先分别输入一个ASCII符号(从33到96)后隐藏,然后挨个猜对方的答案,正确则欢呼并告知猜了多少次,错误则告诉偏大偏小并换另外一个人猜。猜完后,会提问是否继续,继续则重新开始,否则结束....
#include <time.h>
main()
{
 int a,b,c;
 printf("Player A, please write your number and press enter to keep it secret: ",a);
 scanf("%d", &a);
 system("cls");
 printf("Player B, please write your number and press enter to keep it secret:",b);
 scanf("%d",&b);
 system("cls");
 printf("Come on! Show Time!");
 while(a)
 {
 int i=0;
 printf("Player A, Please write the number you guess:");
 scanf("%d",&c);
 if(c==b)
 {
  printf ("OMG,congratulations!you get the correct answer!\n");
  printf ("You have tried %d times\n",i);
  i++;
  break; }
 
  if(c>b)
   printf("well, your number is too large and turn for player B.\n");
   i++;
  if(c<b)
   printf("well,your number is too small and turn for player B.\n");
   i++;
}
return 0
}


不知道怎么记录累积的次数并且换人...求大神讲解
搜索更多相关主题的帖子: include secret please system number 
2016-10-17 19:17
hushuncheng
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2016-10-9
收藏
得分:0 
回复 2楼 word123
哇哇哇!!!谢谢大侠~谢谢大神~
2016-10-18 15:50
快速回复:新手求解大神猜数字问题编法
数据加载中...
 
   



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

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