#include<stdio.h>
#include<windows.h>
#include<string.h>
#include <stdlib.h>
#include <time.h>
#define MAX 2147483647 //
void move(int x, int y)
{
COORD Pos;
Pos.X = y;
Pos.Y = x;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), Pos);
}
int main() {
FILE *fp,*f;
char words[1000] = {},mem[1000];
/*
fp = fopen("C:\\Users\\user\\Downloads\\resultSave.txt", "wt");
if(fp == NULL) {
printf("WT");
return 0;
}
fprintf(fp, "Hello\n");
fclose(fp);
fp = fopen("C:\\Users\\user\\Downloads\\resultSave.txt", "r+");
fscanf(fp, "%s", words);
printf("%s\n", words);
fclose(fp);
*/
printf("※주의! 이 프로그램은 매우 귀찮습니다※");
Sleep(1000);
system("cls");
int x=0,y=0,z=0,i=0,j=0,k=0, th=1,s=0,b=0,o=1,v=0;
char n[10000];
srand(time(NULL));
x=rand()%10;
while(1)
{
y=rand()%10;
if(x!=y)
{
break;
}
}
while(1)
{
z=rand()%10;
if(x!=z&&y!=z)
{
break;
}
}
move(1,1);
printf("┌─┐");
move(2,1);
printf("│?│");
move(3,1);
printf("└─┘");
move(1,5);
printf("┌─┐");
move(2,5);
printf("│?│");
move(3,5);
printf("└─┘");
move(1,9);
printf("┌─┐");
move(2,9);
printf("│?│");
move(3,9);
printf("└─┘");
//│─ ┌┐└┘
while(1)
{
if(_kbhit())
{
move(8,1);
printf("%d번째",th);
move(4,1);
printf("┌─┐");
move(5,1);
printf("│ │");
move(6,1);
printf("└─┘");
move(4,5);
printf("┌─┐");
move(5,5);
printf("│ │");
move(6,5);
printf("└─┘");
move(4,9);
printf("┌─┐");
move(5,9);
printf("│ │");
move(6,9);
printf("└─┘");
i = _getch();
move(5,2);
printf("%d",i-48);
j = _getch();
move(5,6);
printf("%d",j-48);
k = _getch();
move(5,10);
printf("%d",k-48);
printf("\n");
printf("\n");
th+=1;
if(i-48==x || j-48==y || k-48==z)
{
s=1;
}
if((j-48==y&&i-48==x)||(j-48==y&&k==z)||(i-48==x&&k-48==z))
{
s=2;
}
if(k-48==z&&j-48==y&&i-48==x)
{
s=3;
system("cls");
printf("와!! 다 맞혔어!!!");
Sleep(2000);
system("cls");
move(1,1);
printf("닉네임 입력:");
scanf("%s",n);
//f = fopen("C:\\Users\\spca\\Downloads\\resultSave.txt", "r+");
// for(v;v>5;v++)
f = fopen("C:\\Users\\spca\\Downloads\\resultSave.txt", "r+");
fscanf(f, "%s", mem);
fp = fopen("C:\\Users\\spca\\Downloads\\resultSave.txt", "w+");
fprintf(fp, "%s\n%s:%d", mem, n, th-1);
//fprintf(f, "%s", mem);
//fclose(fp);
return 0;
}
if((i-48==y || i-48==z) || (j-48==x || j-48==z) || (k-48==x || k-48==y))
{
b=1;
}
if((((i-48==y || i-48==z) && (j-48==x || j-48==z))) || ((k-48==x || k-48==y) && (i-48==y || i-48==z)) || ((k-48==x || k-48==y) && (j-48==x || j-48==z)))
{
b=2;
}
if((i-48==y || i-48==z) && (j-48==x || j-48==z) && (k-48==x || k-48==y))
{
b=3;
}
o=3-s-b;
printf("s:%d b:%d out:%d",s,b,o);
printf("\n");
s=0;
b=0;
o=0;
if(th==11)
{
system("cls");
printf("실패함ㅠㅠ\n");
printf("정답은 %d %d %d야",x,y,z);
Sleep(2000);
system("cls");
printf("정답은 %d %d %d야",x,y,z);
//fclose(fp);
return 0;
}
}
}
}