diff options
Diffstat (limited to 'šola/ds2/n4.c')
-rw-r--r-- | šola/ds2/n4.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/šola/ds2/n4.c b/šola/ds2/n4.c new file mode 100644 index 0000000..23d73ca --- /dev/null +++ b/šola/ds2/n4.c @@ -0,0 +1,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; +} |