summaryrefslogtreecommitdiff
path: root/display.c
blob: 9ddcf26d7cea8d58ca4df14669f82821e67fecc3 (plain)
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
#include "cell.h"

#include <stdio.h>

void display(struct cell board[9][9])
{
	int x;
	int y;
	int val;
	printf("    A B C  D E F  G H I\n"
	      "   ---------------------\n");
	for (y = 0; y < 9; y++)
	{
		if (y % 3 == 0 && y != 0)
			printf("  |-------+------+------\n");
		printf("%d | ", y + 1);
		for (x = 0; x < 9; x++)
		{
			if (x % 3 == 0 && x != 0)
				printf("|");

			val = board[x][y].val;

			printf("%c ", val == 0? ' ' : val+'0');
		}
		printf("\n");
	}
	printf("\n");
}