小游戏
#include<stdio.h>#include<stdlib.h>
#include <time.h>
void main()
{
srand(time(NULL));
int a = rand() % (50 - 1) + 1;
int c, n = 1;
printf("请输入1-50的随机数:");
scanf_s("%d", &c);
while (1)
{
if (c < 1 || c>50)
{
printf("输入错误,请重新输入:");
scanf_s("%d", &c);
n += 1;
}
else if (c > a)
{
printf("哥,大了大了,请重新输入:");
scanf_s("%d", &c);
n += 1;
}
else if (c < a)
{
printf("格局小啦,请重新输入:");
scanf_s("%d", &c);
n += 1;
}
else
{
printf("答对了,共用了%d次,但是没奖励,哈哈哈",n);
break;
}
}
}
{:9_227:}.. 666
页:
[1]