猜随机数游戏
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
//随机一个1~100的数字,通过键盘输入的数据 根据数据输入进行提示
int main()
{
int value;
int num;
srand((unsigned int)time(NULL));//创建随机数种子time,让当前时间作为随机数种子
num = rand() % 100 + 1;
while(1)
{
scanf("%d",&value);
if(num>value)
{
printf("您输入的数太小啦!\n");
}
else if(num<value)
{
printf("您输入的数太大啦!\n");
}
else
{
printf("恭喜您,答对啦!\n");
break;
}
}
return 0;
}