summaryrefslogtreecommitdiffstats
path: root/mat/advent/8
diff options
context:
space:
mode:
authorsijanec <sijanecantonluka@gmail.com>2020-12-19 00:13:36 +0100
committersijanec <sijanecantonluka@gmail.com>2020-12-19 00:13:36 +0100
commitd8fc5266aefe99ccd5e1f1c0df6a190e56efe828 (patch)
tree01193c2a68fe3f9e8f36d7514da61445e62e5ff7 /mat/advent/8
parentsprasevanje_nem_1_wetter_heute (diff)
downloadsola-gimb-2-d8fc5266aefe99ccd5e1f1c0df6a190e56efe828.tar
sola-gimb-2-d8fc5266aefe99ccd5e1f1c0df6a190e56efe828.tar.gz
sola-gimb-2-d8fc5266aefe99ccd5e1f1c0df6a190e56efe828.tar.bz2
sola-gimb-2-d8fc5266aefe99ccd5e1f1c0df6a190e56efe828.tar.lz
sola-gimb-2-d8fc5266aefe99ccd5e1f1c0df6a190e56efe828.tar.xz
sola-gimb-2-d8fc5266aefe99ccd5e1f1c0df6a190e56efe828.tar.zst
sola-gimb-2-d8fc5266aefe99ccd5e1f1c0df6a190e56efe828.zip
Diffstat (limited to 'mat/advent/8')
-rw-r--r--mat/advent/8/Makefile3
-rwxr-xr-xmat/advent/8/a.outbin0 -> 8440 bytes
-rw-r--r--mat/advent/8/prog.c28
-rwxr-xr-xmat/advent/8/vsotabin0 -> 8344 bytes
-rw-r--r--mat/advent/8/vsota.c11
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
new file mode 100755
index 0000000..9fea777
--- /dev/null
+++ b/mat/advent/8/a.out
Binary files differ
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
new file mode 100755
index 0000000..7581730
--- /dev/null
+++ b/mat/advent/8/vsota
Binary files differ
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;
+}