⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 一个使用VC环境 C语言开发的石头 剪刀 布的游戏
💻 C
字号:
/************************************************************************/
/* main function                                                        */
/************************************************************************/

#include "p_r_s.h"
int main(void)
{
    int win_cnt = 0;
    int lose_cnt = 0;
    int tie_cnt = 0;
    p_r_s player_choice;
    p_r_s machine_choice;
    outcome result;

    srand(time(NULL)); // seed the random number generator
    prf_instruction();
    while ((player_choice = selection_by_player()) != quit)
        switch(player_choice)
        {
        case paper:
        case rock:
        case scissors:
            machine_choice = selection_by_machine();
            result = compare(player_choice,machine_choice);

            printf("\n%s%s\n%s%s\n\n",
                   "The Player choice  :",prf_string_choice(player_choice),
                   "The Machine choice :",prf_string_choice(machine_choice));

            report_and_rabulate(result,&win_cnt,&lose_cnt,&tie_cnt);
            break;
        case game:
             prf_game_status(win_cnt,lose_cnt,tie_cnt);
            break;
        case help:
            prf_help();
            break;
        case instruction:
            prf_instruction();
            break;
        case quit:
            printf("\nYou have quited this game!\n");
            exit(1);
            break;    
        default:
            printf("\nPROGRAMMER ERROR: Cannot get here!\n\n");
            //exit(1);
            break;

        }      
    prf_game_status(win_cnt,lose_cnt,tie_cnt);
    prf_final_status(win_cnt,lose_cnt);
    return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -