diff options
Diffstat (limited to 'mat/advent')
-rw-r--r-- | mat/advent/8/Makefile | 3 | ||||
-rwxr-xr-x | mat/advent/8/a.out | bin | 0 -> 8440 bytes | |||
-rw-r--r-- | mat/advent/8/prog.c | 28 | ||||
-rwxr-xr-x | mat/advent/8/vsota | bin | 0 -> 8344 bytes | |||
-rw-r--r-- | mat/advent/8/vsota.c | 11 |
5 files changed, 42 insertions, 0 deletions
diff --git a/mat/advent/8/Makefile b/mat/advent/8/Makefile new file mode 100644 index 0000000..ec92f02 --- /dev/null +++ b/mat/advent/8/Makefile @@ -0,0 +1,3 @@ +default: + gcc prog.c + gcc vsota.c -ovsota diff --git a/mat/advent/8/a.out b/mat/advent/8/a.out Binary files differnew file mode 100755 index 0000000..9fea777 --- /dev/null +++ b/mat/advent/8/a.out diff --git a/mat/advent/8/prog.c b/mat/advent/8/prog.c new file mode 100644 index 0000000..172cbe0 --- /dev/null +++ b/mat/advent/8/prog.c @@ -0,0 +1,28 @@ +#include <stdio.h> +#include <stdlib.h> +int main (int argc, char ** argv) { + if (argc != 1+3) { + fprintf(stderr, "uporaba: %s <od> <do> <n>\nprimer: %s 1000 9999 8499\n", argv[0], argv[0]); + return 1; + } + unsigned long long int o = strtoull(argv[1], NULL, 10); + unsigned long long int d = strtoull(argv[2], NULL, 10); + unsigned long long int n = strtoull(argv[3], NULL, 10); + unsigned long long int i = o; + unsigned long long int j = o; + unsigned long long int s = 0; + for (i = o; i <= d; i++) { + fprintf(stderr, "\rpreostane še %llu iteracij", n-i); + s = 0; + for (j = o; j <= d; j++) { + if (j == i) + continue; + s += j; + } + if (n * i == s) + break; + } + fprintf(stdout, "\rče seštejemo vsa števila od %llu do %llu, razen %llu, bo\n" + "vsota vseh %llu, kar je %llu*%llu.\n", o, d, i, s, n, i); + return 0; +} diff --git a/mat/advent/8/vsota b/mat/advent/8/vsota Binary files differnew file mode 100755 index 0000000..7581730 --- /dev/null +++ b/mat/advent/8/vsota diff --git a/mat/advent/8/vsota.c b/mat/advent/8/vsota.c new file mode 100644 index 0000000..50d4ef6 --- /dev/null +++ b/mat/advent/8/vsota.c @@ -0,0 +1,11 @@ +#include <stdio.h> +#include <stdlib.h> +int main (int argc, char ** argv) { + unsigned long long int a = 0; + unsigned long long int i = 0; + for (i = 1000; i <= 9999; i++) { + a += i; + } + fprintf(stdout, "rezultat vsote je: %llu\n", a); + return 0; +} |