-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.c
64 lines (60 loc) · 1.24 KB
/
test.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <math.h>
int axis[8][8];
static void arraysetup(int player_x, int player_y)
{
int randx = rand() % 8;
int randy = rand() % 8;
int x = player_x + 4;
int y = player_y + 4;
if ((randx + 1) == x && (randy + 1) == y)
{
while (1)
{
if ((randx + 1) == x && (randy + 1) == y)
{
randx = rand() % 8;
randy = rand() % 8;
}
else
{
break;
}
}
}
for (int i = 0; i < 8; i++)
{
for (int i1 = 0; i1 < 8; i1++)
{
if (i == randx && i1 == randy)
{
axis[i + 1][i1 + 1] = 1;
}
else
{
axis[i + 1][i1 + 1] = 0;
}
if (x == i && y == i1)
{
axis[i][i1] = 2;
}
printf("%d", axis[i + 1][i1 + 1]);
}
printf("\n");
}
}
int main()
{
int px, py;
while (1)
{
px = rand() % 9 - 4;
py = rand() % 9 - 4;
system("clear");
arraysetup(px, py);
printf("\n%d : %d\n",px, py);
sleep(1);
}
}