rand猜数游戏
#include <stdio.h>#include <stdlib.h>
void main()
{
int guess,magic;
magic = rand(); //rand()这是一个取伪随机数的随机函数,srand是取真随机数的函数。
printf("please enter a guess number:\n");
scanf("%d",&guess);
if (guess==magic)
printf("Gratulation! You Are Right.\n");
else
printf("Sorry, You Are Wrong.\n");
}