summaryrefslogtreecommitdiffstats
path: root/mat/euler/16/mnozi.c
diff options
context:
space:
mode:
Diffstat (limited to 'mat/euler/16/mnozi.c')
-rw-r--r--mat/euler/16/mnozi.c31
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