用C语言编一个猜数字的小游戏
1个回答
展开全部
/*以前自己写的一个小程序,可以提示大或小。你看着改改吧,就是把随机数范围那儿加上两个选择就行了*/
#include<stdlib.h>
#include<time.h>
#include<stdio.h>
int
juge(int
a,int
b);
int
main()
{
int
g,temp;
randomize();
temp=random(1000);
printf("System
will
produce
a
number
between
0--999
automaticly!\n\n");
printf("\nInput
your
number:\n\n");
scanf("%d",&g);
printf("\nYou
have
tried
%d
times!",juge(g,temp));
getch();
}
int
juge(int
a,int
b)
{int
i;
for(i=1;a!=b;i++)
{if(a<b)
{printf("Your
number
is
smaller!
(%d
times)\n\n",i);
scanf("%d",&a);
}
else
{printf("Your
number
is
bigger!
(%d
times)\n\n",i);
scanf("%d",&a);
}
}
printf("\nVery
good!!!\n");
return
i;
}
#include<stdlib.h>
#include<time.h>
#include<stdio.h>
int
juge(int
a,int
b);
int
main()
{
int
g,temp;
randomize();
temp=random(1000);
printf("System
will
produce
a
number
between
0--999
automaticly!\n\n");
printf("\nInput
your
number:\n\n");
scanf("%d",&g);
printf("\nYou
have
tried
%d
times!",juge(g,temp));
getch();
}
int
juge(int
a,int
b)
{int
i;
for(i=1;a!=b;i++)
{if(a<b)
{printf("Your
number
is
smaller!
(%d
times)\n\n",i);
scanf("%d",&a);
}
else
{printf("Your
number
is
bigger!
(%d
times)\n\n",i);
scanf("%d",&a);
}
}
printf("\nVery
good!!!\n");
return
i;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询