回答編集履歴

5

空白調整

2020/05/23 10:34

投稿

shiracamus
shiracamus

スコア5406

test CHANGED
@@ -64,7 +64,7 @@
64
64
 
65
65
  }
66
66
 
67
- for (int i = n-1; i>=0; i--){
67
+ for (int i = n - 1; i >= 0; i--) {
68
68
 
69
69
  printf("%d", answer[i]);
70
70
 

4

スペース調整

2020/05/23 10:34

投稿

shiracamus
shiracamus

スコア5406

test CHANGED
@@ -32,11 +32,11 @@
32
32
 
33
33
  ```c
34
34
 
35
- #include<stdio.h>
35
+ #include <stdio.h>
36
36
 
37
37
 
38
38
 
39
- int main(void){
39
+ int main(void) {
40
40
 
41
41
  int n;
42
42
 

3

配列サイズを80に変更

2020/05/23 10:32

投稿

shiracamus
shiracamus

スコア5406

test CHANGED
@@ -42,9 +42,9 @@
42
42
 
43
43
  scanf("%d", &n);
44
44
 
45
- int value[81] = {9};
45
+ int value[80] = {9};
46
46
 
47
- int answer[81];
47
+ int answer[80];
48
48
 
49
49
  int carry = 0;
50
50
 

2

誤字訂正

2020/05/23 10:31

投稿

shiracamus
shiracamus

スコア5406

test CHANGED
@@ -26,7 +26,7 @@
26
26
 
27
27
 
28
28
 
29
- radianさんのコメントに書かれたコードを改良してました。
29
+ radianさんのコメントに書かれたコードを改良してました。
30
30
 
31
31
 
32
32
 

1

改良コード追記

2020/05/23 10:26

投稿

shiracamus
shiracamus

スコア5406

test CHANGED
@@ -23,3 +23,57 @@
23
23
  =1368
24
24
 
25
25
  ```
26
+
27
+
28
+
29
+ radianさんのコメントに書かれたコードを改良していました。
30
+
31
+
32
+
33
+ ```c
34
+
35
+ #include<stdio.h>
36
+
37
+
38
+
39
+ int main(void){
40
+
41
+ int n;
42
+
43
+ scanf("%d", &n);
44
+
45
+ int value[81] = {9};
46
+
47
+ int answer[81];
48
+
49
+ int carry = 0;
50
+
51
+ while (carry == 0) {
52
+
53
+ for (int i = 0; i < n; i++) {
54
+
55
+ answer[i] = value[i]; // copy last value to answer
56
+
57
+ carry += value[i] * 3;
58
+
59
+ value[i] = carry % 10;
60
+
61
+ carry /= 10;
62
+
63
+ }
64
+
65
+ }
66
+
67
+ for (int i = n-1; i>=0; i--){
68
+
69
+ printf("%d", answer[i]);
70
+
71
+ }
72
+
73
+ printf("\n");
74
+
75
+ return 0;
76
+
77
+ }
78
+
79
+ ```