📄 compare.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 + -