diff options
author | sijanec <sijanecantonluka@gmail.com> | 2020-12-08 22:14:47 +0100 |
---|---|---|
committer | sijanec <sijanecantonluka@gmail.com> | 2020-12-08 22:14:47 +0100 |
commit | 1784430e7ffd5849a14297f3da144153f326204f (patch) | |
tree | 19a4464518180af262dd4f668a893e057c780dee /mat/euler/17/prog.c | |
parent | sam commitam, awful bug, končni return je pisal return i namesto return z xddd (diff) | |
download | sola-gimb-2-1784430e7ffd5849a14297f3da144153f326204f.tar sola-gimb-2-1784430e7ffd5849a14297f3da144153f326204f.tar.gz sola-gimb-2-1784430e7ffd5849a14297f3da144153f326204f.tar.bz2 sola-gimb-2-1784430e7ffd5849a14297f3da144153f326204f.tar.lz sola-gimb-2-1784430e7ffd5849a14297f3da144153f326204f.tar.xz sola-gimb-2-1784430e7ffd5849a14297f3da144153f326204f.tar.zst sola-gimb-2-1784430e7ffd5849a14297f3da144153f326204f.zip |
Diffstat (limited to '')
-rw-r--r-- | mat/euler/17/prog.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/mat/euler/17/prog.c b/mat/euler/17/prog.c new file mode 100644 index 0000000..afa005d --- /dev/null +++ b/mat/euler/17/prog.c @@ -0,0 +1,28 @@ +#include <stdio.h> +#include <stdlib.h> +#define DISABLE_LIB_TESTS 1 +#include <angnum.c> +int main (int argc, char ** argv) { + if (argc != 1+2) { + fprintf(stderr, "uporaba: %s <stevilka>\nprimer-sešteje črke v ang številih od 1 do 1000: %s 1 1000\n", argv[0], argv[0]); + return 1; + } + long long int a = strtoll(argv[1], NULL, 10); + long long int b = strtoll(argv[2], NULL, 10); + unsigned long long int i = 0; // lenasI + long long int j = 0; // Janez je podpisan, da se po 0 ne obrne (: + unsigned long long int e = 0; // sEštevek + char * s = malloc(sizeof(char)*MX_NS_L); + for (i = a; i <= b; i++) { + // fprintf(stderr, "\rračunam ... preostane še %llu operacij.", b-i); + j = angnum(i, s, MX_NS_L); + if (j == 0) + return 2; + for (j-- /* da ne gledamo nul bajta na koncu (: */ ; j >= 0; j--) { + if (s[j] >= 'a' && s[j] <= 'z') // that's why I like C + e++; + } + } + fprintf(stdout, "\rkonec. seštevek črk je %llu.\n", e); + return 0; +} |