新手求解大神猜数字问题编法
程序内容:两个人互相猜数字,先分别输入一个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
}
不知道怎么记录累积的次数并且换人...求大神讲解