diff options
author | Anton Luka Šijanec <anton@sijanec.eu> | 2024-05-14 22:19:27 +0200 |
---|---|---|
committer | Anton Luka Šijanec <anton@sijanec.eu> | 2024-05-14 22:19:27 +0200 |
commit | f65e7733a59efe8bfd8cfe33e699c1e750deb274 (patch) | |
tree | ae8918ee0766f26f3c74b1d97a5edbbb550d5646 /šola/ds2/n4.c | |
parent | dn08 (diff) | |
download | r-f65e7733a59efe8bfd8cfe33e699c1e750deb274.tar r-f65e7733a59efe8bfd8cfe33e699c1e750deb274.tar.gz r-f65e7733a59efe8bfd8cfe33e699c1e750deb274.tar.bz2 r-f65e7733a59efe8bfd8cfe33e699c1e750deb274.tar.lz r-f65e7733a59efe8bfd8cfe33e699c1e750deb274.tar.xz r-f65e7733a59efe8bfd8cfe33e699c1e750deb274.tar.zst r-f65e7733a59efe8bfd8cfe33e699c1e750deb274.zip |
Diffstat (limited to '')
-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; +} |