#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);
}
/*
int main() {
int x, y;
int px=15, py=15;
int c = 0;
for(;;) {
x = 0;
y = 0;
gotoxy(x, y);
printf("*");
Sleep(100);
gotoxy(px, py);
printf("Dash Count is %d", c++);
gotoxy(x, y);
printf(" ");
}
}
*/
int main()
{
char words[10][20] = {"apple", "kiwi", "melon", "banana", "mandarin", "orange"};
char p[10]= {};
char ans[20] = {0};
char inp;
int r, x, y, a, b, c=0, i,j, g=0, t=0;
int k=0;
int px=15, py=15;
srand(time(NULL));
for(;;)
{
gotoxy(x, y);
printf("Dash Count is %d\n", c++);
Sleep(100);
for(;;)
{
//r이 중복해서 나왔다면?
r = rand()%6;
if(p[r]==0)
{
p[r]=1;
break;
}
}
printf("answer is %s\n", words[r]);
for(;;)
{
scanf(" %c", &inp);
t=0;
for(i=0; i<strlen(words[r]); i++)
{
if(inp==words[r][i])
{
ans[i]=1;
}
t += ans[i];
}
if(t == strlen(words[r]))
{
printf("문제를 맞췄습니다!!!\n");
break;
}
for(i=0; i<strlen(words[r]); i++)
{
if(ans[i]==0)
{
printf("_");
}
else
{
printf("%c", words[r][i]);
}
}
printf("\n");
}
printf("다시 시작하고 싶으면1, 끝내고 싶으면 2: ");
scanf("%d", &g);
if(g == 1)
{
for(i=0; i<20; i++)
{
ans[i] = 0;
}
system("cls");
}
else if(g == 2)
{
return 0;
}
else
{
printf("하, 숫자 1, 2만 입력하라고 했는데 허허허허허ㅓ ");
return 0;
}
}
}
//횟수세기 최우선