[컴퓨터 프로그램][C++]C++을 이용한 가위바위보 프로그램

이미지
준비중입니다.
※ 미리보기 이미지는 최대 20페이지까지만 지원합니다.
  • 분야
  • 등록일
  • 페이지/형식
  • 구매가격
  • 적립금
자료 다운로드  네이버 로그인
소개글
[컴퓨터 프로그램][C++]C++을 이용한 가위바위보 프로그램에 대한 자료입니다.
목차
키보드로 가위(S), 바위(R), 보(P)를 입력하여 컴퓨터와 가위바위보를 할 수있도록 만든 프로그램입니다.
게임상태표시(G), 도움기능(H)도 제공하여 편리하게 사용할 수 있는 프로그램입니다.
본문내용
/* 가위, 바위, 보 규칙 보는 바위를 이긴다.
바위는 가위를 이긴다. 가위는 보를 이긴다. */
#include
#include
#include
#include

enum p_r_s {paper, rock, scissors,
game, help, instructions, quit};
enum outcome {win, lose, tie, error};

typedef enum p_r_s p_r_s;
typedef enum outcome outcome ;

outcome compare(p_r_s player_choice,
p_r_s machine_choice);
void prn_final_status(int win_cnt, int lose_cnt);
void prn_game_status(int win_cnt,
int lose_cnt, int tie_cnt);
void prn_help(void);
void prn_instructions(void);
void report_and_tabulate(outcome result,
int *win_cnt_ptr, int *lose_cnt_ptr, int *tie_cnt_ptr);
p_r_s selection_by_machine(void);
p_r_s selection_by_player(void);

/* main.c */
int main(void)
{
int win_cnt = 0, lose_cnt = 0, tie_cnt = 0;
outcome result;
p_r_s player_choice, machine_choice;

srand(time(NULL));
prn_instructions();
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);
report_and_tabulate(result, &win_cnt,
&lose_cnt, &tie_cnt);
break;
case game:
prn_game_status(win_cnt, lose_cnt, tie_cnt);
break;
case instructions:
prn_instructions();
break;
case help:
prn_help();
break;
default:
printf("\n프로그래머 오류!\n\n");
exit(1);
}
prn_game_status(win_cnt, lose_cnt, tie_cnt);
prn_final_status(win_cnt, lose_cnt);
return 0;
}
하고 싶은 말
C언어를 이용한 간단한 가위바위보 프로그램 입니다.
대학1학년생들의 초반 레포트로 유용한
간단한 프로그램입니다.