#include <stdlib.h>
#include <time.h>
#define N 10
main()
{
int i,a,b
srand(time(0))/*设置种子,并生成伪随机序列*/液樱
while(~scanf("%d",&b))
{
for(i=0i<N++i) rand()%10
a = rand()%100
while(1)
{
if(a == b) {puts(" 恭喜你档衫 猜对了 !\n***************\n") break}
else if(a >b) puts("你输入的行埋腔数 小了!")
else puts("你输入的数 大了!")
scanf("%d",&b)
}
}
system("pause")
}
/*利用随机函数生成0---9之间的一个整数,从键盘输入数字猜该数,每次提示输入的数字与生成的数字之间的大小关系,并统计猜数的次数?
徊轮泻笙允靖檬�⒉率�拇问�暗燃?三次以内为优缺胡册秀,七次以内为良好,
否则为不及格)。 */
#include <stdio.h>
#include <stdlib.h>做前
int main()
{
int data, t, count = 0
data = rand()%9
do
{
printf("enter the integer you guess:")
scanf("%d", &t)
if (data == t)
{
printf("the data is:%d\n", data)
break
}
else if(data >t)
{
printf("a little smaller\伏宏n")
}
else
{
printf("a little bigger\n")
}
count++
}while(1)
if (count <= 3)
{
printf("优")
}
else if(count <= 7)
{
printf("良")
}
else
{
printf("不及格")
}
return 0
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)