게시판 즐겨찾기
편집
드래그 앤 드롭으로
즐겨찾기 아이콘 위치 수정이 가능합니다.
[본삭금]가위바위보 함수에 횟수추가 하려하는데 방법좀 가르쳐주세요~..
게시물ID : programmer_10086짧은주소 복사하기
작성자 : Karise
추천 : 0
조회수 : 366회
댓글수 : 3개
등록시간 : 2015/05/15 11:10:21
옵션
  • 베스트금지
  • 본인삭제금지
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <time.h>
#include <stdlib.h>

static const char *CHOICE[] = {"가위", "바위", "보"};
static const char *WIN = "승";
static const char *LOSE = "패";
static const char *TIE = "비김";

void main(void)
{
int iRandom = 0; // 1(가위), 2(바위), 3(보)
int iSelection = 0;

// 컴퓨터의 랜덤값 지정
srand(time(0));
iRandom = (rand() % 3) + 1;

printf("1(가위), 2(바위), 3(보) 입력 : _\b");
scanf("%d", &iSelection);

printf("\n 사용자 : %s", CHOICE[iSelection - 1]);
printf("\n 컴퓨터 : %s\n\n", CHOICE[iRandom - 1]);

//결과출력
if (iSelection == iRandom)
{
printf(TIE);
}
else
{
switch (iSelection)
{
case 1: printf(iRandom == 3 ? WIN: LOSE); break;
case 2: printf(iRandom == 1 ? WIN: LOSE); break;
case 3: printf(iRandom == 2 ? WIN: LOSE); break;
}
}
printf("\n");
}

여기에서 횟수를 추가 하고 싶은데... 
이제 막 배우는 거다보니 어떤 함수를 이용해야할지부터 감이 안옵니다..ㄷㄷ
출처 본인..
꼬릿말 보기
전체 추천리스트 보기
새로운 댓글이 없습니다.
새로운 댓글 확인하기
글쓰기
◀뒤로가기
PC버전
맨위로▲
공지 운영 자료창고 청소년보호