回答編集履歴

2

完了

2018/04/15 22:12

投稿

asm
asm

スコア15147

test CHANGED
@@ -1,12 +1,40 @@
1
- **製作中**
2
-
3
1
  isdigitやatoiを使う方法
4
2
 
5
3
 
6
4
 
7
5
  ```
8
6
 
7
+ #include <stdio.h>
8
+
9
+ #include <string.h>
10
+
11
+ #include <stdlib.h>
12
+
13
+ #include <ctype.h>
14
+
9
- main(){
15
+ int main(){
16
+
17
+ const char* str = "123987";
18
+
19
+ int size = 0;
20
+
21
+ int* n = malloc(sizeof(int) * strlen(str));
22
+
23
+ char b[2] = {0};
24
+
25
+ for(int i = 0; isdigit(str[i]); i++){
26
+
27
+ b[0] = str[i];
28
+
29
+ n[size++] = atoi(b);
30
+
31
+ }
32
+
33
+ for(int i = 0; i < size; i++){
34
+
35
+ printf("%d => %d\n", i, n[i]);
36
+
37
+ }
10
38
 
11
39
  }
12
40
 

1

途中

2018/04/15 22:12

投稿

asm
asm

スコア15147

test CHANGED
@@ -1,3 +1,5 @@
1
+ **製作中**
2
+
1
3
  isdigitやatoiを使う方法
2
4
 
3
5
 
@@ -7,3 +9,5 @@
7
9
  main(){
8
10
 
9
11
  }
12
+
13
+ ```