aboutsummaryrefslogtreecommitdiff
path: root/Computer_Science/leetcode/59-spiral_matrix_II.c~
blob: 7276575ba4e3bc3e4e37a6ca56a0f996324d6d4f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/**
 * Return an array of arrays.
 * Note: The returned array must be malloced, assume caller calls free().
 */
int** generateMatrix(int n) {
	int **matrix = malloc(sizeof(int *) * n);
	int offset = 0;
	int maxOffset = n / 2 + 1;

	for(int i = 0; i < n; i++)
		*(matrix + i) = malloc(sizeof(int) * n);
	for(offset = 0; offset < maxOffset; offset++, n -= 2) {
		if(n == 0)
			return;
		else if(n == 1)
			matrix
}