#include <stdio.h>
#include <math.h>
#include <time.h>
#include <windows.h>
#define LEFT 75
#define RIGHT 77
#define UP 72
#define DOWN 80
void gotoxy(int x,int y)
{
COORD pos= {x,y};
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos);
}
int main()
{
char n;
int a=5,b=5,x=0,y=0,v=0,i;
while(1)
{
gotoxy(a,b);
printf(" ");
a=a+x;
b=b+y;
gotoxy(a,b);
printf("0");
if (kbhit())
{
n = getch();
switch (n)
{
case LEFT:
x=-1;
y=0;
break;
case RIGHT:
x=1;
y=0;
break;
case UP:
y=-1;
x=0;
break;
case DOWN:
y=1;
x=0;
break;
}
}
if (x!=0)
{
Sleep(20);
}
else{
Sleep(40);
}
}
return 0;