/*
#include <stdio.h>
int main()
{
int n,i,j,arr[1000],a,b=0,c;
scanf("%d",&n);
for(i=0; i<n; i++)
{
scanf("%d",&arr[i]);
}
if(n==2)
{
if(arr[1]<arr[2])
{
printf("0");
return 0;
}
else
{
printf("1");
}
}
for(i=0; i<n-1; i++)
{
for(j=0; j<=n-i-2; j++)
{
c=0;
if(arr[j]>arr[j+1])
{
a=arr[j];
arr[j]=arr[j+1];
arr[j+1]=a;
c++;
}
}
b++;
if(c==0)
{
printf("%d",b);
return 0;
}
}
return 0;
}
*/
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<windows.h>
#include<string.h>
void gotoxy(int x,int y)
{
COORD pos= {x,y};
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos);
}
int main()
{
char word[10][20] = {"apple", "orange", "banana", "melon", "computer", "mouse", "smartphone", "water", "cat", "dog"};
char quest[20] = {};
int check[20] = {0};
int n, k,i;
char p, v;
int count=10;
int a=0;
srand(time(NULL));
while(1)
{
printf("문제를 하나 만들까요?:");
scanf("%d", &n);
if(n==1)
{
k = rand()%10;
strcpy(quest, word[k]); // quest < word[k] 복사하기
printf("%s\n", quest);
break;
}
}
// quest < word
// orange > _r_n__
// 10
system("cls");
while(1)
{
// chook ha hap ni da
//system("cls");
gotoxy(5, 5);
printf("input your alphabet : ");
scanf(" %c", &p);
v = 0;
gotoxy(20, 7);
printf("answer is : ");
for(i=0; i<strlen(quest); i++)
{
if(p==quest[i] && check[i]==0)
{
printf("%c", quest[i]);
check[i]=1;
v = 1;
}
else if(check[i]==1)
{
printf("%c", quest[i]);
}
else
{
printf("_");
}
}
for(i=0; i<n; i++)
{
if(quest[i]=='_')
{
a=1;
}
}
if(a==0)
{
gotoxy(15,15);
printf("chook ha hap ni da");
}
if(v==0)
{
count--;
}
gotoxy(20, 3);
printf("%02d\n",count);
if(count==0)
{
break;
}
}
}