首页 > 学院 > 开发设计 > 正文

猜数游戏

2019-11-17 05:37:19
字体:
来源:转载
供稿:网友

  /*猜数游戏*/
       /*程序产生一个随机数,游戏者输入数据进行猜测。治理员可输入密码,
       其中普通治理员只能获得答案,超级治理员获得答案并能修改普通治理员密码*/
        #include<stdio.h>
        #include<stdlib.h>
        #include<time.h>
        
        #define NO 0
        #define YES 1
        #define QU99v -1
        #define EASY 1
        #define COMMON 2
        #define HARD 3
        #define PASSWord2 -111111 /*超级治理员密码,不可修改*/
      
         char *PasswordName= "LiangJianbin";/*超级治理员确认密码,不可修改*/
         int Password1 =111111 ;  /*普通治理员密码,可修改*/
         int number;       /*计算机产生的随机数*/
         int guess_value=0; /*游戏者输入的猜测数*/
         int nbr_of_guesses=0;/*累加游戏者猜测的次数*/
         int done=0;  /*标记游戏者是否猜对,若猜对则  done=1*/
     
     
        void the_back_door(int password,int answer);  /*开个后门好作弊,判定普通或超级治理员*/
        void super_Adm_menu(int answer); /*超级治理员选择菜单*/
        void game_introdUCtion(void);/*游戏介绍,选择游戏级别或退出*/
        void quit_or_not(void);    /*确认是否退出*/
        void change_password(int answer);/*修改普通治理员密码*/
        void input_data(void);/*输入数据或退出,治理员可输入密码*/
        void congratulate(void) ;  /*祝贺猜对并问是否继续*/
        int judge(void);/*判定数据是否正确*/
        void enter_password_name(char *true_password);/*确认超级治理员*/  
        
        int main(void)
        {
            game_introduction();/*游戏介绍,选择游戏级别或退出*/
            system("pause");
            return 0;
             
         }    
                
            
     void game_introduction(void)/*游戏介绍,选择游戏级别或退出*/
     {
            int selection;
            int flag=0;/*循周游戏介绍标志,选择游戏级别或退出后flag=1,循环结束*/  
            do
            {
                nbr_of_guesses=0;
                puts("This is a guess number game.You can input a number to guess.");
                
                do
                {
                      puts("/n1--Get a easy degree.");
                      puts("/n2--Get a common degree.");
                      puts("/n3--Get a hard  degree.");
                      puts("/n-1--Quit the game.");
                      puts("/nEnter a selection.");
                
                      scanf("%d",&selection);
               }while(selection!=-1&&selection<1selection>3);
            
               if(selection==EASY)
               {
                     PRintf("/n/nGetting a Random number/n");
                    /*产生随机数*/
                    srand( (unsigned) time(NULL));
                    number=rand();
                    flag=1;
               }
               else if  (selection==COMMON)
               {
           
                    printf("/n/nGetting a Random number/n");
                    /*产生随机数*/
                    srand( (unsigned) time(NULL));
 &nb


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表