1-3
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#define NUM1 15
int main()
{
srand(time(NULL));
int randnum = -999 + rand() % 1998, import;
printf("%d", randnum);
printf("请猜猜-999到999之间的数\n\n");
int number = NUM1;
int number1[NUM1] = { 0 };
do {
printf("你还有%d次机会哦!是多少呢:", number);
scanf("%d", &import);
number1[number - 1] = import;
number--;
if (import > randnum) {
printf("有点大了\n");
}
else if (import < randnum) {
printf("有点小了哦\n");
}
} while (import != randnum && number > 0);
if (import != randnum) {
printf("不好意思,你没有猜对哦!正确的数是%d\n", randnum);
}
else {
printf("非常好,你用了%d次猜对了%d\n", NUM1 - number, randnum);
}
printf("---------你猜的所有的数是----------\n");
for (int i = 0; i < NUM1 - number; i++) {
printf("第%d次是:%d\n", i + 1, number1[NUM1-i-1]);
}
return 0;
}