summaryrefslogtreecommitdiffstats
path: root/mat/euler/9/prog.c
diff options
context:
space:
mode:
Diffstat (limited to 'mat/euler/9/prog.c')
-rw-r--r--mat/euler/9/prog.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/mat/euler/9/prog.c b/mat/euler/9/prog.c
new file mode 100644
index 0000000..6aee0e9
--- /dev/null
+++ b/mat/euler/9/prog.c
@@ -0,0 +1,24 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+int main(int argc, char ** argv) {
+ if (argc != 1+4) {
+ fprintf(stderr, "uporaba: %s <sestevek a+b+c> <min> <max> <step>\nprimer: %s 1000 1 100 1\n", argv[0], argv[0]);
+ return 1;
+ }
+ unsigned int i;
+ double j[3];
+ double n[1];
+ double min = atoi(argv[2]);
+ double max = atoi(argv[3]);
+ double step = atoi(argv[4]);
+ for (i = 1; i <= 1; 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 ((j[0] < j[1] < j[2]) && (j[0] + j[1] + j[2] == n[0])
+ && (pow(j[0],2) + pow(j[1],2) == pow(j[2],2)))
+ fprintf(stdout, "našel: %f^2 + %f^2 = %f^2 ; %f+%f+%f=%f\n", j[0],j[1], j[2], j[0], j[1], j[2], j[0]+j[1]+j[2]);
+ return 0;
+}