FreeFoxCM

一个猜数程序
 1/*猜数程序,该程序随机生成一个数字,并判断输入值和随机数的大小关系*/
 2/*编写者:FreeFox*/
 3/***********************************************/
 4#include <stdio.h>
 5#include <time.h>
 6#include <stdlib.h>
 7
 8int main(void)
 9{
10 int GuessValue,Number,NbrOfGuess=0;
11
12 srand((unsigned) time(NULL));
13 Number=rand();
14 //Number=50;
15 while(NbrOfGuess <= 10)
16 {
17
18  printf("\nInput you guess value:");
19  scanf("%d",&GuessValue);
20  printf("\n");
21  if (GuessValue > Number)
22  {
23   printf("You guess value is greater than actual value!");
24   ++NbrOfGuess;
25  }

26  else
27             if (GuessValue < Number)
28    {
29    printf("You guess value is less-than actual value!");
30    ++NbrOfGuess;
31    }

32      else
33           {
34                printf("Very Good!\n");
35       printf("You all use %d times",++NbrOfGuess);
36       break;
37     }

38 }

39 printf("Game Over!");
40 return 0;
41}

42/* CopyRight @2006 FreeFox All right reserved */
43

posted on 2008-06-17 15:08  FreeFox  阅读(135)  评论(0)    收藏  举报