C++을 이용한 가위바위보 프로그램
본 자료는 미리보기를 지원하지 않습니다.
닫기
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
해당 자료는 3페이지 까지만 미리보기를 제공합니다.
3페이지 이후부터 다운로드 후 확인할 수 있습니다.

소개글

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;
}

키워드

  • 가격2,000
  • 페이지수10페이지
  • 등록일2006.05.30
  • 저작시기2005.12
  • 파일형식압축파일(zip)
  • 자료번호#351887
본 자료는 최근 2주간 다운받은 회원이 없습니다.
청소해
다운로드 장바구니