回答編集履歴

1

バグ修正

2020/11/29 17:57

投稿

kazuma-s
kazuma-s

スコア8224

test CHANGED
@@ -30,11 +30,15 @@
30
30
 
31
31
  }
32
32
 
33
+ listnew[i+digit2] += carry;
34
+
35
+ carry = 0;
36
+
33
37
  }
34
38
 
35
39
  int k = digit1 + digit2 - 1;
36
40
 
37
- if (carry) listnew[k++] = carry;
41
+ if (listnew[k]) k++;
38
42
 
39
43
  return k;
40
44
 
@@ -50,11 +54,11 @@
50
54
 
51
55
  int list1[10] = { 3, 2, 1 }, list2[10] = { 3, 2, 1 };
52
56
 
53
- int listnew[10] = { 0 };
57
+ int listnew[22] = { 0 };
54
58
 
55
59
  int k = multiply(n1, n2, list1, list2, listnew);
56
60
 
57
- for (int i = k; --i >= 0; ) printf("%d", listnew[i]);
61
+ for (int i = k; --i >= 0; ) putchar(listnew[i] + '0');
58
62
 
59
63
  putchar('\n');
60
64