/*
#include <stdio.h>
#include <stdlib.h>
int main()
{
printf("Hello world!\n");
return 0;
}
*/
/*
#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(".");
}
}
}
}
}
*/
/*
#include<stdio.h>
int main()
{
int map[105][105]={0};
int i,j,n,x[100]={0},y[100]={0},a,b,k=0;
scanf ("%d",&n);
for(i=0;i<n;i++)
{
scanf ("%d %d",&x[i],&y[i]);
for(a=x[i];a<x[i]+10;a++)
{
for(b=y[i];b<y[i]+10;b++)
{
map [a][b] = 1;
}
}
}
for(i=0;i<100;i++)
{
for(j=0;j<100;j++)
{
if(map[i][j]==1)
{
k++;
}
}
}
printf ("%d",k);
return 0;
}
*/
/*
#include <stdio.h>
int main()
{
int i,n;
double a,b,k=0,d=0,sum=0;
n=5;
for(i=0;i<n;i++)
{
scanf ("%lf %lf",&a,&b);
k=b-a;
if(k>=1)
{
k=0;
}
else
{
k-=1;
}
if(k>4)
{
k=4;
}
sum+=k;
}
if(sum>=15)
{
d=sum*10000*0.95;
}
else if(sum<=5)
{
d=sum*10000*1.05;
}
else
{
d=sum*10000;
}
printf ("%lf",d);
}
*/