summaryrefslogtreecommitdiffstats
path: root/šola/ds2/n4.c
blob: 23d73caec404114f29cb05b958870fb1596d5355 (plain) (blame)
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
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#define KVADRAT(x) ((x)*(x))
int main (int argc, char ** argv) {
	assert(argc >= 2);
	int n = atoi(argv[1]);
	int povezanost[n*n][n*n];
	for (int i = 0; i < n*n; i++) {
		for (int j = 0; j < n*n; j++) {
			int istolpec = i/n;
			int ivrstica = i%n;
			int jstolpec = j/n;
			int jvrstica = j%n;
			povezanost[i][j] = KVADRAT(istolpec-jstolpec)+KVADRAT(jvrstica-ivrstica) == 5 ? 1 : 0;
		}
	}
	for (int i = 0; i < n*n; i++) {
		for (int j = 0; j < n*n; j++) {
			printf("%d\t", povezanost[i][j]);
		}
		printf("\n");
	}
	return 0;
}