#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(" ");
}
}
*/
char words[4][10][20] = {{"apple", "kiwi", "melon", "banana", "mandarin", "orange"},{"bus","taxi","bmw"},{"teacher","firefighter"},{"beef","pork"}};
char words2[10][20]= {"fruit", "car", "job", "meat"};
char p[4][10]= {};
char ans[20] = {0};
char inp;
int r, x, y, a, b, c=0, i,j, g=0, t=0, l=0;
int k=0;
int px=15, py=15;
void game(int sub)
{
srand(time(NULL));
gotoxy(0, 0);
printf("Dash Count is %d\n", c++);
for(;;)
{
//r이 중복해서 나왔다면?
r = rand()%6;
if(p[sub][r]==0)
{
p[sub][r]=1;
break;
}
}
printf("answer is %s\n", words[sub][r]);
for(;;)
{
gotoxy(0, 5);
scanf(" %c", &inp);
gotoxy(0, 0);
printf("Dash Count is %d\n", c++);
gotoxy(3, 3);
t=0;
for(i=0; i<strlen(words[r]); i++)
{
if(inp==words[sub][r][i])
{
ans[i]=1;
}
t += ans[i];
}
if(t == strlen(words[sub][r]))
{
printf("문제를 맞췄습니다!!!\n\n");
break;
}
for(i=0; i<strlen(words[sub][r]); i++)
{
if(ans[i]==0) printf("_");
else printf("%c", words[sub][r][i]);
}
printf("\n");
}
}
int main()
{
for(;;)
{
c=0;
printf("chose!: \n");
for(i=0; i<4; i++) printf("%d. %s ",i+1,words2[i]);
scanf("%d", &l);
system("cls");
game(l-1);
c=0;
for(i=0;i<6;i++) c+=p[l][i];
if(c==6) {printf("준비된 게임이 다 끝났습니다."); return 0;}
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;
}
}
}
/* for(i=0; i<4; i++)
{
printf("%d. %s\n",i+1,words2[i]);
}
if(l==1)
{
printf("%s", words[i][r]);
system("cls");
}
*/