summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xmat/advent/2/a.outbin0 -> 12624 bytes
-rw-r--r--mat/advent/2/prog.c25
2 files changed, 25 insertions, 0 deletions
diff --git a/mat/advent/2/a.out b/mat/advent/2/a.out
new file mode 100755
index 0000000..00889d8
--- /dev/null
+++ b/mat/advent/2/a.out
Binary files differ
diff --git a/mat/advent/2/prog.c b/mat/advent/2/prog.c
new file mode 100644
index 0000000..663fe8f
--- /dev/null
+++ b/mat/advent/2/prog.c
@@ -0,0 +1,25 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+int main(int argc, char ** argv) {
+ if (argc != 1+11) {
+ fprintf(stderr, "uporaba: %s <stevilka> (=) <stevilka>(x) (+) <stevilka>(y) (+) <stevilka>(z) (;) <stevilka> (=) <stevilka>(x) (+) <stevilka>(y) (+) <stevilka>(z) <min> <max> <step>\nprimer: %s 53 3 2 5 91 5 3 9 0 100 1\n", argv[0], argv[0]);
+ return 1;
+ }
+ unsigned int i;
+ double j[3];
+ double n[8];
+ double min = atoi(argv[9]);
+ double max = atoi(argv[10]);
+ double step = atoi(argv[11]);
+ for (i = 1; i <= 8; i++)
+ n[i-1] = atof(argv[i]);
+ for (j[0] = min; j[0] <= max; j[0]++)
+ for (j[1] = min; j[1] <= max; j[1]++)
+ for (j[2] = min; j[2] <= max; j[2]++)
+ if ((n[0] == n[1] * j[0] + n[2] * j[1] + n[3] * j[2])
+ && (n[4] == n[5] * j[0] + n[6] * j[1] + n[7] * j[2]))
+ fprintf (stdout, "našel: %f = %f * %f + %f * %f + %f * %f ; "
+ "%f = %f * %f + %f * %f + %f * %f\n", n[0], n[1], j[0], n[2], j[1], n[3], j[2], n[4], n[5], j[0], n[6], j[1], n[7], j[2]);
+ return 0;
+}