質問編集履歴
3
見出しも追加しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -60,11 +60,11 @@
|
|
60
60
|
|
61
61
|
```
|
62
62
|
|
63
|
-
|
63
|
+
###関連するソースコード
|
64
64
|
|
65
65
|
```
|
66
66
|
|
67
|
-
|
67
|
+
ノードの定義や、ノードを作成、リストを表示する関数も付記します。
|
68
68
|
|
69
69
|
●ノードの定義
|
70
70
|
|
2
問題のあるコードと、関連コードとを分割して表示するようにしました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -57,6 +57,12 @@
|
|
57
57
|
}
|
58
58
|
|
59
59
|
|
60
|
+
|
61
|
+
```
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
```
|
60
66
|
|
61
67
|
*ノードの定義や、ノードを作成、リストを表示する関数も付記します。
|
62
68
|
|
1
```でソースコードを閉じ、インシデントを表示するようにしました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -14,45 +14,47 @@
|
|
14
14
|
|
15
15
|
###該当のソースコード
|
16
16
|
|
17
|
-
```C
|
18
17
|
|
18
|
+
|
19
|
+
```lang-C
|
20
|
+
|
19
|
-
node_t
|
21
|
+
node_t nodeReverse(node_t **ndPtrPtr)
|
20
22
|
|
21
23
|
{
|
22
24
|
|
23
|
-
int
|
25
|
+
int i = 0;
|
24
26
|
|
25
|
-
node_t
|
27
|
+
node_t *Pro_ptr1;
|
26
28
|
|
27
|
-
|
29
|
+
node_t *Pro_ptr2;
|
28
30
|
|
29
|
-
while(*ndPtrPtr
|
31
|
+
while(*ndPtrPtr != NULL){
|
30
32
|
|
31
|
-
|
33
|
+
if(i == 0){
|
32
34
|
|
33
|
-
|
35
|
+
Pro_ptr1 = *ndPtrPtr;
|
34
36
|
|
35
|
-
|
37
|
+
ndPtrPtr = &((*ndPtrPtr) -> next);
|
36
38
|
|
37
|
-
|
39
|
+
Pro_ptr1 -> next = NULL;
|
38
40
|
|
39
|
-
|
41
|
+
}else if(i != 0){
|
40
42
|
|
41
|
-
|
43
|
+
Pro_ptr2 = *ndPtrPtr;
|
42
44
|
|
43
|
-
|
45
|
+
ndPtrPtr = &((*ndPtrPtr) -> next);
|
44
46
|
|
45
|
-
|
47
|
+
Pro_ptr2 -> next = Pro_ptr1;
|
46
48
|
|
47
|
-
|
49
|
+
Pro_ptr1 = Pro_ptr2;
|
48
50
|
|
49
|
-
|
51
|
+
}
|
50
52
|
|
51
|
-
|
53
|
+
i++;
|
52
54
|
|
53
55
|
}
|
54
56
|
|
55
|
-
}
|
57
|
+
}
|
56
58
|
|
57
59
|
|
58
60
|
|
@@ -60,105 +62,101 @@
|
|
60
62
|
|
61
63
|
●ノードの定義
|
62
64
|
|
63
|
-
typedef
|
65
|
+
typedef int data_t;
|
64
66
|
|
65
|
-
|
66
|
-
|
67
|
-
typedef
|
67
|
+
typedef struct nodetag
|
68
68
|
|
69
69
|
{
|
70
70
|
|
71
|
-
data_t
|
71
|
+
data_t data;
|
72
72
|
|
73
|
-
struct
|
73
|
+
struct nodetag *next;
|
74
74
|
|
75
|
-
}node_t;
|
75
|
+
}node_t;
|
76
76
|
|
77
77
|
|
78
78
|
|
79
79
|
●ノードの作成
|
80
80
|
|
81
|
-
node_t
|
81
|
+
node_t *nodeNew(data_t dt, node_t *nxt)
|
82
82
|
|
83
83
|
{
|
84
84
|
|
85
|
-
node_t
|
85
|
+
node_t *ndPtr;
|
86
86
|
|
87
|
-
|
87
|
+
ndPtr = malloc(sizeof(node_t));
|
88
88
|
|
89
|
-
ndPtr
|
89
|
+
if(ndPtr == NULL){
|
90
90
|
|
91
|
-
if(ndPtr == NULL){
|
92
|
-
|
93
|
-
return
|
91
|
+
return NULL;
|
94
92
|
|
95
93
|
}else{
|
96
94
|
|
97
|
-
ndPtr
|
95
|
+
ndPtr -> data = dt;
|
98
96
|
|
99
|
-
|
97
|
+
ndPtr -> next = nxt;
|
100
98
|
|
101
|
-
|
99
|
+
return ndPtr;
|
102
100
|
|
103
101
|
}
|
104
102
|
|
105
103
|
}
|
106
104
|
|
107
|
-
|
105
|
+
|
108
106
|
|
109
107
|
●リストにノードを後から加える関数
|
110
108
|
|
111
|
-
int
|
109
|
+
int nodeAppend(node_t **ndPtrPtr, data_t dt)
|
112
110
|
|
113
111
|
{
|
114
112
|
|
115
|
-
node_t
|
113
|
+
node_t *ndPtr;
|
116
114
|
|
117
|
-
|
115
|
+
ndPtr = nodeNew(dt, NULL);
|
118
116
|
|
119
|
-
ndPtr
|
117
|
+
if(ndPtr == NULL){
|
120
118
|
|
121
|
-
if(ndPtr == NULL){
|
122
|
-
|
123
|
-
return
|
119
|
+
return FAILURE;
|
124
120
|
|
125
121
|
}
|
126
122
|
|
127
|
-
|
123
|
+
|
128
124
|
|
129
|
-
while(*ndPtrPtr
|
125
|
+
while(*ndPtrPtr != NULL){
|
130
126
|
|
131
|
-
ndPtrPtr
|
127
|
+
ndPtrPtr = &((*ndPtrPtr) -> next);
|
132
128
|
|
133
129
|
}
|
134
130
|
|
135
|
-
*ndPtrPtr
|
131
|
+
*ndPtrPtr = ndPtr;
|
136
132
|
|
137
|
-
return
|
133
|
+
return SUCCESS;
|
138
134
|
|
139
|
-
}
|
135
|
+
}
|
140
136
|
|
141
137
|
|
142
138
|
|
143
139
|
●リストの表示
|
144
140
|
|
145
|
-
void
|
141
|
+
void listPrint(node_t *ndPtr)
|
146
142
|
|
147
143
|
{
|
148
144
|
|
149
145
|
printf("{");
|
150
146
|
|
151
|
-
while(ndPtr
|
147
|
+
while(ndPtr != NULL){
|
152
148
|
|
153
|
-
printf("%d",
|
149
|
+
printf("%d", ndPtr -> data);
|
154
150
|
|
155
|
-
|
151
|
+
ndPtr = ndPtr -> next;
|
156
152
|
|
157
153
|
}
|
158
154
|
|
159
155
|
printf("}\n");
|
160
156
|
|
161
|
-
}
|
157
|
+
}
|
158
|
+
|
159
|
+
```
|
162
160
|
|
163
161
|
|
164
162
|
|
@@ -173,3 +171,11 @@
|
|
173
171
|
###補足情報(言語/FW/ツール等のバージョンなど)
|
174
172
|
|
175
173
|
使用開発環境:BCC Developer 1.2.21
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
###最後に
|
178
|
+
|
179
|
+
機能をうまく活用できず、分かりにくい表示で最初投稿してしまいました。
|
180
|
+
|
181
|
+
申し訳ありません。
|