/*
#include <stdio.h>
#include <stdlib.h>
int main()
{
printf("Hello world!\n");
return 0;
*/
/*
#include<stdio.h>
#include<string.h>
#include<windows.h>
#include<math.h>
#include<time.h>
void gotoxy(int x,int y)
{
COORD pos= {x,y};
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos);
}
int main()
{
char input,p,words[5][10] = {"hello","fineapple","mango","banana","melon"};
char answer[10] = {0};
srand(time(NULL));
int randomNumber;
int c=20,k,i;
srand(time(NULL));
gotoxy(44,1);
printf("---------------------");
gotoxy(48,2);
printf("HANG MAN GAME");
gotoxy(44,3);
printf("---------------------");
gotoxy(47,7);
printf("PRESS 'E' or 'e'");
for(;;)
{
if(kbhit())
{
input = getch();
if(input=='E'||input=='e')
{
system("cls");
gotoxy(50,13);
printf("LET'S START!");
Sleep(1000);
system("cls");
break;
}
}
}
gotoxy(50,13);
printf("알파벳을 입력해주세요");
randomNumber = rand()%strlen(words);
for(;;)
{
system("cls");
for(i=0; i<strlen(words[randomNumber]); i++)
{
gotoxy(50,1);
printf ("기회 : %d",c);
gotoxy(50+i,14);
if(answer[i]==0)
{
printf("_");
}
else
{
printf("%c", words[randomNumber][i]);
}
}
gotoxy(50, 15);
scanf(" %c", &p);
for(i=0; i<strlen(words[randomNumber]); i++)
{
if(p==words[randomNumber][i])
{
answer[i] = 1;
}
if(c==0)
{
c--;
break;
gotoxy(50,20);
printf ("Game Over!");
}
}
/*
gotoxy(57,13);
scanf("%c",&p);
gotoxy(57,13);
printf(" ");
*/
/*}
/*
}
/*
*/
/*
#include<stdio.h>
#include<windows.h>
#include<stdlib.h>
#include<math.h>
#include<time.h>
#define LEFT 75
#define RIGHT 77
#define UP 72
#define DOWN 80
int map[100][100] = {0};
int resourceTable[15] = {0};
void gotoxy(int x,int y)
{
COORD pos= {x,y};
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos);
}
void intMap()
{
for(int i=0; i<100; i++)
{
for(int j=0; j<100; j++)
{
if(i>=10)
{
map[i][j] = 9;
}
else
{
map[i][j] = 0;
}
gotoxy(j, i);
switch(map[i][j])
{
case 0:
printf(".");
break;
case 9:
printf("M");
break;
}
}
}
}
char drawBefore(int x, int y)
{
switch(map[x][y])
{
case 0:
return '.';
case 9:
return 'M';
}
}
char drawAfter(int x, int y)
{
}
// nothing:0, dirt:1, silver:2, gold:3,dia:4
int randomResource()
{
int r = rand()%100000000; // 1억
if(r < 50000000)
{
return 0;
}
else if(r < 75000000)
{
return 1;
}
else if(r < 90000000)
{
return 2;
}
else if(r < 99000000)
{
return 3;
}
else
{
return 4;
}
}
void resourceViewer()
{
char name[15][10] = {"", "dirt", "silver", "gold", "dia"};
gotoxy(103, 2);
for(int i=1; i<15; i++)
{
gotoxy(103, 2+i);
printf("%6s: %05d", name[i], resourceTable[i]);
}
}
int main()
{
char input;
int x=9, y=20;
srand(time(NULL));
intMap();
resourceViewer();
gotoxy(y, x);
printf("@");
gotoxy(0,0);
printf(".");
while(1)
{
if(kbhit())
{
input = getch();
switch(input)
{
case LEFT:
gotoxy(y, x);
printf("%c", drawBefore(x, y));
y--;
gotoxy(y, x);
printf("@");
break;
case RIGHT:
gotoxy(y, x);
printf("%c", drawBefore(x, y));
y++;
gotoxy(y, x);
printf("@");
break;
case UP:
gotoxy(y, x);
printf("%c", drawBefore(x, y));
x--;
gotoxy(y, x);
printf("@");
break;
case DOWN:
if(map[x+1][y]==9)
{
continue;
}
gotoxy(y, x);
printf("%c", drawBefore(x, y));
x++;
gotoxy(y, x);
printf("@");
break;
case 's':
case 'S':
if(map[x+1][y]==9)
{
resourceTable[randomResource()] += (rand()%3+1);
resourceViewer();
map[x+1][y]=0;
gotoxy(y,x+1);
printf(".");
}
case 'D':
case 'd':
if(map[x+1][y]==9)
{
resourceTable[randomResource()] += (rand()%3+1);
resourceViewer();
map[x][y+1]=0;
gotoxy(y+1,x);
printf(".");
}
case 'A':
case 'a':
if(map[x+1][y]==9)
{
resourceTable[randomResource()] += (rand()%3+1);
resourceViewer();
map[x+1][y]=0;
gotoxy(y+1,x);
printf(".");
}
case 'W':
case 'w':
if(map[x+1][y]==9)
{
resourceTable[randomResource()] += (rand()%3+1);
resourceViewer();
map[x][y+1]=0;
gotoxy(y,x+1);
printf(".");
}
}
}
}
}
*/