首页 > 代码库 > 简单猜数游戏2

简单猜数游戏2

/*简单猜数游戏,magic number#2,版本*/
#include<stdio.h>
#include<stdlib.h>

int main(void)
{
int magic; /*magic number*/
int guess; /*user‘s guess*/
printf("\nWelcome to the magic number game\n");
magic=rand(); /*产生随机数*/
printf("\nGuess the magic number:");
scanf("%d",&guess);

if(guess==magic)
{
printf("***Right***\n");
printf("%d is the magic number\n",magic);
}
else
{
printf("Wrong,");
if(guess>magic)
printf("too high\n");
else
printf("too low\n");
}
system("PAUSE");
return 0;
} /*end main*/

简单猜数游戏2