diff options
Diffstat (limited to '')
-rw-r--r-- | šola/p1/dn/DN01_naivno.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/šola/p1/dn/DN01_naivno.c b/šola/p1/dn/DN01_naivno.c new file mode 100644 index 0000000..ae6547c --- /dev/null +++ b/šola/p1/dn/DN01_naivno.c @@ -0,0 +1,21 @@ +#include <stdio.h> +#include <stdlib.h> +int main (int argc, char ** argv) { + if (argc != 3) { + fprintf(stderr, "%s a b\n", argv[0]); + return 1; + } + int a = atoi(argv[1]); + int b = atoi(argv[2]); + if (b < a) { + int temp = a; + a = b; + b = temp; + } + int sum = 0; + for (int s = 1; s < a; s++) { + fprintf(stderr, "D: %d\ts=%d, a=%d, b=%d\n", (a-s)*(b-s), s, a, b); + sum += (a-s)*(b-s); + } + printf("%d\n", sum); +} |