diff options
author | sijanec <sijanecantonluka@gmail.com> | 2020-12-08 00:18:37 +0100 |
---|---|---|
committer | sijanec <sijanecantonluka@gmail.com> | 2020-12-08 00:18:37 +0100 |
commit | bcb05e675c287755a2be90723fc214281f3c4278 (patch) | |
tree | 9911b49c064d8ff6e01387e6edda4ed8d04b36d8 /mat/euler/16/mnozi.c | |
parent | advent 4 fix, remove debug (diff) | |
download | sola-gimb-2-bcb05e675c287755a2be90723fc214281f3c4278.tar sola-gimb-2-bcb05e675c287755a2be90723fc214281f3c4278.tar.gz sola-gimb-2-bcb05e675c287755a2be90723fc214281f3c4278.tar.bz2 sola-gimb-2-bcb05e675c287755a2be90723fc214281f3c4278.tar.lz sola-gimb-2-bcb05e675c287755a2be90723fc214281f3c4278.tar.xz sola-gimb-2-bcb05e675c287755a2be90723fc214281f3c4278.tar.zst sola-gimb-2-bcb05e675c287755a2be90723fc214281f3c4278.zip |
Diffstat (limited to '')
-rw-r--r-- | mat/euler/16/mnozi.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/mat/euler/16/mnozi.c b/mat/euler/16/mnozi.c new file mode 100644 index 0000000..f90cdbd --- /dev/null +++ b/mat/euler/16/mnozi.c @@ -0,0 +1,31 @@ +#pragma once +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +int mnozi (unsigned long long int mnozi_s_tem, char * d, long int b) { + unsigned long long int carry = 0; // carry je pri množenju vedno pozitiven + unsigned long long int to = 0; + unsigned long long int za_napisati = 0; + for (b = b-1; b >= 0; b--) { + to = d[b] - '0'; + za_napisati = to * mnozi_s_tem; + za_napisati = za_napisati + carry; + carry = 0; + if (za_napisati > 9) { + za_napisati = za_napisati - 10; + carry++; + } + d[b] = za_napisati + '0'; + } + return 0; +} +#ifndef DISABLE_LIB_TESTS +int main (int argc, char ** argv) { + unsigned long long int m = 2; + char d[] = "0000000000000000000000000000000000000000000000000000456"; + int b = strlen(d); + mnozi(m, d, b); + fprintf(stdout, "test: %s\n", d); + return 0; +} +#endif |