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