C语言数数问题!
为什么我输入不了甲乙两人所猜的次数?#include<stdio.h>#include<stdlib.h>#include<time.h>intx,y;intmain()...
为什么我输入不了甲乙两人所猜的次数?
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int x,y;
int main()
{
int guess(),a,b;
printf("请甲开始猜数");
guess (1);
printf("甲猜了%d次",&x);
printf("请乙开始猜数");
guess (2);
printf("乙猜了%d次",&y);
if(a>b)
printf("乙获胜");
else
printf("甲获胜");
return 0;
}
int guess(int num)
{
int magic,i,n;
srand(time(0));
magic=rand()%10+1;
while(1)
{
scanf("%d",&n);
i++;
if(magic==n)
break;
if(magic<n)
printf("大了");
if(magic>n)
printf("小了");
}
if(num=1)
x=i;
else
if(num=2)
y=i;
return magic;
} 展开
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int x,y;
int main()
{
int guess(),a,b;
printf("请甲开始猜数");
guess (1);
printf("甲猜了%d次",&x);
printf("请乙开始猜数");
guess (2);
printf("乙猜了%d次",&y);
if(a>b)
printf("乙获胜");
else
printf("甲获胜");
return 0;
}
int guess(int num)
{
int magic,i,n;
srand(time(0));
magic=rand()%10+1;
while(1)
{
scanf("%d",&n);
i++;
if(magic==n)
break;
if(magic<n)
printf("大了");
if(magic>n)
printf("小了");
}
if(num=1)
x=i;
else
if(num=2)
y=i;
return magic;
} 展开
展开全部
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main()
{ int guess(),a,b;
printf("请甲开始猜数:\n");
a=guess ();
printf("甲猜了%d次\n",a);
printf("请乙开始猜数:\n");
b=guess ();
printf("乙猜了%d次\n",b);
if(a>b)
printf("乙获胜\n");
else
if(a<b)
printf("甲获胜\n");
else
printf("平局\n");
return 0;
}
int guess()
{ int magic,i=0,n;
srand(time(0));
magic=rand()%10+1;
while(1)
{ scanf("%d",&n);
i++;
if(magic==n)
break;
if(magic<n)
printf("大了");
if(magic>n)
printf("小了");
}
return i;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询