diff options
author | sijanec <sijanecantonluka@gmail.com> | 2020-12-03 17:08:39 +0100 |
---|---|---|
committer | sijanec <sijanecantonluka@gmail.com> | 2020-12-03 17:08:39 +0100 |
commit | 190507a0a05e7a6292b41bec529910ecfcbb69fb (patch) | |
tree | 20105249580655bc8b5bf47ea9ebf0e543fa06e7 /mat/euler/9 | |
parent | naredil 8. nalogo eulerja (diff) | |
download | sola-gimb-2-190507a0a05e7a6292b41bec529910ecfcbb69fb.tar sola-gimb-2-190507a0a05e7a6292b41bec529910ecfcbb69fb.tar.gz sola-gimb-2-190507a0a05e7a6292b41bec529910ecfcbb69fb.tar.bz2 sola-gimb-2-190507a0a05e7a6292b41bec529910ecfcbb69fb.tar.lz sola-gimb-2-190507a0a05e7a6292b41bec529910ecfcbb69fb.tar.xz sola-gimb-2-190507a0a05e7a6292b41bec529910ecfcbb69fb.tar.zst sola-gimb-2-190507a0a05e7a6292b41bec529910ecfcbb69fb.zip |
Diffstat (limited to 'mat/euler/9')
-rw-r--r-- | mat/euler/9/Makefile | 2 | ||||
-rwxr-xr-x | mat/euler/9/a.out | bin | 0 -> 8568 bytes | |||
-rw-r--r-- | mat/euler/9/prog.c | 24 |
3 files changed, 26 insertions, 0 deletions
diff --git a/mat/euler/9/Makefile b/mat/euler/9/Makefile new file mode 100644 index 0000000..20eb4bf --- /dev/null +++ b/mat/euler/9/Makefile @@ -0,0 +1,2 @@ +default: + gcc -pedantic prog.c -lm diff --git a/mat/euler/9/a.out b/mat/euler/9/a.out Binary files differnew file mode 100755 index 0000000..103d407 --- /dev/null +++ b/mat/euler/9/a.out 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; +} |