summaryrefslogtreecommitdiffstats
path: root/mat/euler/4
diff options
context:
space:
mode:
authorsijanec <sijanecantonluka@gmail.com>2020-12-03 17:08:39 +0100
committersijanec <sijanecantonluka@gmail.com>2020-12-03 17:08:39 +0100
commit190507a0a05e7a6292b41bec529910ecfcbb69fb (patch)
tree20105249580655bc8b5bf47ea9ebf0e543fa06e7 /mat/euler/4
parentnaredil 8. nalogo eulerja (diff)
downloadsola-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/4')
-rw-r--r--mat/euler/4/Makefile2
-rwxr-xr-xmat/euler/4/a.outbin0 -> 8576 bytes
-rw-r--r--mat/euler/4/prog.c28
3 files changed, 30 insertions, 0 deletions
diff --git a/mat/euler/4/Makefile b/mat/euler/4/Makefile
new file mode 100644
index 0000000..2def8af
--- /dev/null
+++ b/mat/euler/4/Makefile
@@ -0,0 +1,2 @@
+default:
+ gcc prog.c
diff --git a/mat/euler/4/a.out b/mat/euler/4/a.out
new file mode 100755
index 0000000..336eb2e
--- /dev/null
+++ b/mat/euler/4/a.out
Binary files differ
diff --git a/mat/euler/4/prog.c b/mat/euler/4/prog.c
new file mode 100644
index 0000000..151dea9
--- /dev/null
+++ b/mat/euler/4/prog.c
@@ -0,0 +1,28 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+int main(int argc, char ** argv) {
+ if (argc != 1+2) {
+ fprintf(stderr, "uporaba: %s <min> <max>\nprimer: %s 100 999\n", argv[0], argv[0]);
+ return 1;
+ }
+ size_t i, k;
+ unsigned long long int d = 0;
+ unsigned long long int j[2];
+ unsigned long long int min = atoi(argv[1]);
+ unsigned long long int max = atoi(argv[2]);
+ unsigned long long int step = 1;
+ char s[256] = "";
+ for (j[0] = min; j[0] <= max; j[0]++)
+ for (j[1] = min; j[1] <= max; j[1]++) {
+ sprintf(s, "%lld", j[0]*j[1]);
+ i = strlen(s);
+ for (k = 0; k < i; k++)
+ if (s[k] != s[(i-1)-k])
+ break;
+ else if (k >= i-1 && d < j[0]*j[1])
+ d = j[0]*j[1];
+ }
+ fprintf(stdout, "konec. našel največji palindrom %lld.\n", d);
+ return 0;
+}