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

📄 compare.c

📁 一个使用VC环境 C语言开发的石头 剪刀 布的游戏
💻 C
字号:
/* Compare the choice of the player and the machine*/

#include "p_r_s.h"

outcome compare(p_r_s player_choice,p_r_s machine_choice)
{
    outcome result;
    if (player_choice == machine_choice)
    {
        result = tie;
    }
    else
    {
        switch(player_choice)
        {
        case paper:
            result = (machine_choice == rock)? win : lose;
        	break;
        case rock:
            result = (machine_choice == scissors)? win : lose;
        	break;
        case scissors:
            result = (machine_choice == paper)? win : lose;
            break;
        default:
            printf("\n PROGRAMMER ERROR : Unexpected choice! \n\n");
            exit(1);
            break;
        }
    }
    return result;
}

⌨️ 快捷键说明

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