compare.c
来自「一个使用VC环境 C语言开发的石头 剪刀 布的游戏」· C语言 代码 · 共 32 行
C
32 行
/* 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 + =
减小字号Ctrl + -
显示快捷键?