标题:新手求解大神猜数字问题编法
取消只看楼主
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



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-469909-1-1.html




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

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