출처 : 반크_세계유산 고인돌
참고풀이]
//Dev-C++ 5.11로 작업함.
#include <stdio.h>
#include <stdlib.h> //srand(), rand()
#include <time.h> //time()
int main()
{
enum Game { kawee, bawee, bo};
int N; //player 변수
int C; //컴퓨터 변수
int chk; //결과승부 변수
//무작위 값을 산출하기 위한 초가값 설정
srand(time(NULL));
printf("가위(0), 바위(1), 보(2)를 입력하세요 : ");
scanf("%d",&N);
C=rand()%3;
if(N==C) chk=0;
else if(N==kawee)
if(C==bo) chk=1;
else if(C==bawee)chk=-1;
else if(N==bawee)
if(C==kawee) chk=1;
else if(C==bo) chk=-1;
else if(N==bo)
if(C==bawee) chk=1;
else if(C==kawee) chk=-1;
if(chk==1)
printf("Player가 이겼습니다.\n");
else if(chk==-1)
printf("Computer가 이겼습니다.\n");
else
printf("비겼습니다.\n");
return 0;
}
참고풀이 결과]
대한민국의 아름다운 영토, 독도
'프로그램 > C언어 1000제' 카테고리의 다른 글
C언어 109제] C언어 콘서트 CHAPTER 12 Programming 1 파일의 내용 읽어서 화면에 출력하기 p488 (0) | 2022.01.21 |
---|---|
C언어 108제] C언어 콘서트 CHAPTER 12 p469 도전문제 특수문자 제거 (0) | 2022.01.19 |
C언어 106제] C언어 콘서트 CHAPTER 11 Programming 6 재고를 검색하기 p456 (0) | 2022.01.18 |
C언어 105제] C언어 콘서트 CHAPTER 11 Programming 5 나이가 20이상 30 이하인 직원 출력하기 p456 (0) | 2022.01.18 |
C언어 104제] C언어 콘서트 CHAPTER 11 Programming 4 두시간 사이의 차이를 계산하기 p455 (0) | 2022.01.17 |
댓글