-
Notifications
You must be signed in to change notification settings - Fork 0
/
find_spot.c
49 lines (47 loc) · 1.35 KB
/
find_spot.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* find_spot.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cosney <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/24 03:34:35 by cosney #+# #+# */
/* Updated: 2020/04/24 05:03:35 by cosney ### ########.fr */
/* */
/* ************************************************************************** */
int *empty_spots(char board[][9], int *pos, char n, int k)
{
int x;
int y;
int j;
int count;
x = 1;
while (x < (k + 1))
{
count = 0;
j = 1;
while (j < (k + 1))
{
if (board[x][j] == n)
count++;
j++;
}
if (count < 1)
{
y = 1;
while (y < (k + 1))
{
if (board[x][y] == '0')
{
pos[0] = x;
pos[1] = y;
return (pos);
}
y++;
}
}
x++;
}
pos[0] = -1;
return (0);
}