哪位大神来看看,int和long???
#include <stdio.h>#include <stdlib.h>
#include <time.h>
#define GUESS_LIMIT 1000
char *infos[] = {
"【猜数游戏已启动】\n数字已经设定好,请玩家进行猜测,数字范围在0~%d\n",
"猜测数字大了!请继续猜测:",
"猜测数字小了!请继续猜测:",
"恭喜猜中数字!!!共猜测了%d次\n"
};
int guess_program(){
int target_num, guess_num, guess_time;
guess_time = 0;
target_num = rand() % (GUESS_LIMIT + 1);
printf(infos[0], GUESS_LIMIT);
do{
printf(">>");
scanf("%d", &guess_num);
guess_time++;
if (guess_num > target_num)
printf("%s\n", infos[1]);
else if (guess_num < target_num)
printf("%s\n", infos[2]);
} while (guess_num != target_num);
printf(infos[3], guess_time);
return 0;
}
int main()
{srand(time(NULL));
guess_program();
return 0;
}