1-100的随机数猜测小游戏
#include<stdio.h>//1-100的随机数猜测小游戏
#include<stdlib.h>
#include<time.h>
int main()
{
int value;
int num;
srand((unsigned int)time(NULL));
num = rand()%100+1;
while(1)
{
scanf("%d",&value);
if(num>value)
{
printf("太小了,继续\n");
}
else if(num<value)
{
printf("太大了,继续\n");
}
else
{
printf("恭喜你,猜对了\n");
break;
}
}
}
页:
[1]