热门

最新

红包

立Flag

投票

同城

我的

发布
m0_58759749
Drag0n-Dance
4 年前
truem0_58759749

猜随机数游戏

#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;
}

CSDN App 扫码分享
分享
评论
1
打赏
  • 复制链接
  • 举报
下一条:
MakeFile文件在编写的时候,一定要注意对应的文件夹是否存在,MakeFile不会在没有文件夹的情况下去生成对应的文件夹,而是会选择报错
立即登录