#include <stdio.h>
#include<math.h>
#include <time.h>
#include <windows.h>
void gotoxy(int x,int y)
{
COORD pos= {x,y};
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos);
}
void setColor(int x)
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),x);
}
int main(void)
{
int k,i,b=0,c=0,d=0,u=0,j=0,p=6,g;
char a[100][20]= {"you","we","diy"};
char answer[20] = {0};
char input;
srand(time(NULL));
k = rand()%3;
setColor(4);
gotoxy(10,9);
printf("몫슴");
gotoxy(10,12);
setColor(2);
printf("단어입력");
gotoxy(10,10);
setColor(2);
while (1)
{
gotoxy(10,10);
//printf("%s %d",a[k], strlen(a[k]));
for(i=0; i<strlen(a[k]); i++)
{
if(answer[i]==1)
{
printf("%c ", a[k][i]);
u++;
}
else
{
printf("_ ");
}
}
if(j==u)
{
p--;
}
gotoxy(13,9);
printf(" %d",p);
j=u;
u=0;
if(p==0)
{gotoxy(10,13);
setColor(4);
printf("GAME OVER");
return 0;
}
printf("\n");
for(i=0; i<strlen(a[k]); i++)
{
if(answer[i]==1)
{
b=b+1;
}
}
if(b==strlen(a[k]))
{
gotoxy(10,13);
printf("축하해");
break;
}
gotoxy(19,12);
scanf(" %c", &input);
for(i=0; i<strlen(a[k]); i++)
{
if(input == a[k][i])
{
answer[i]=1;
}
}
b=0;
Sleep(100);
}
return 0;
}