#include <stdio.h>
#include <string.h>
#include <windows.h>
#include <time.h>
#include <stdlib.h>
#include <math.h>
#define MAXSIZE 10
int main()
{
char quest[MAXSIZE][20] = {"banana", "apple", "mandarin", "car", "computer", "mango", "bean", "meam", "picture", "media"};
int res[20] = {0};
int i, j, k, n, m, x;
int r;
int life;
char y;
srand(time(NULL));
while(1)
{
printf("Game Start?(1:start, 2:end) : ");
scanf("%d", &x);
if(x==2)
return 0;
if(x==1)
{
life = 10;
// 문자를 찾추면 깍이지 않음
// 문자를 못맞추면 라이프가 깍임
// 라이프가 0이 되면 문제를 맞춘것과 상관없이 실패(fail)
// 중복된 값을 입력해도 life가 1이 감소함
// 예 : Computer 에서 C를 연속으로 친 경우 -1 라이프
//
r = rand()%MAXSIZE;
printf("%s\n", quest[r]);
while(1)
{
for(i=0; i<strlen(quest[r]); i++)
{
if(quest[r][i]==y)
{
res[i]=1;
}
}
for(j=0; j<strlen(quest[r]); j++)
{
if(res[j]==1)
{
printf("%c", quest[r][j]);
}
else
{
printf("_");
}
}
m = 0;
for(n=0; n<strlen(quest[r]); n++)
{
m += res[n];
}
if(m == strlen(quest[r]))
{
printf("\nGame End");
}
printf("\n");
scanf(" %c",&y);
}
}
}
return 0;
}