forked from Aisthetic/GoGame
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgrid.c
More file actions
61 lines (52 loc) · 1.2 KB
/
Copy pathgrid.c
File metadata and controls
61 lines (52 loc) · 1.2 KB
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
//Formatte et affiche une ligne donnée de la grille
void printLine(char line[]){
//Chaque boucle doit afficher un char du tableau puis '|'
for (int i = 0; i < 8; ++i)
{
printf("%c-----", line[i] );
}
printf("%c\n", line[8]);
}
void printGrid(char ** grid){
int i,j;
//affiche les coord horizontales
printf(" ");
for (j = 0; j < 8; ++j)
{
printf("%d ", j+1);
}
printf("9\n");
for (i = 0; i < 8; ++i)
{
printf(" %d ", i+1);
printLine(grid[i]);
printf(" ");
//Boucle pour afficher les '| | | | | |'
for (int j = 0; j < 8; ++j)
{
printf("| ");
}
printf("|\n");
printf(" ");
for (int k = 0; k < 8; ++k)
{
printf("| ");
}
printf("|\n");
}
printf(" 9 ");
printLine(grid[8]);
}
//Retourne une grille vide
char ** getBlankGrid(){
char ** mat = (char *) malloc((sizeof(char *))*9);
int i=0,j=0;
for(i=0; i<9; i++)
mat[i] = (char *) malloc(sizeof(char)*9);
for(i=0; i<9; i++){
for(j=0; j<9; j++){
mat[i][j] = ' ';
}
}
return mat;
}