質問編集履歴
5
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -150,7 +150,7 @@
|
|
150
150
|
|
151
151
|
|
152
152
|
|
153
|
-
void put_strary2(c
|
153
|
+
void put_strary2(char s[][A], int n)
|
154
154
|
|
155
155
|
{
|
156
156
|
|
4
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -140,12 +140,6 @@
|
|
140
140
|
|
141
141
|
#define A 128
|
142
142
|
|
143
|
-
#define _CRT_SECURE_NO_WARNINGS
|
144
|
-
|
145
|
-
#define N 128
|
146
|
-
|
147
|
-
#define A 128
|
148
|
-
|
149
143
|
#include <stdio.h>
|
150
144
|
|
151
145
|
#include <string.h>
|
3
解決後のコードを追加しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -125,3 +125,121 @@
|
|
125
125
|
なぜi=0になってしまうのか理由が知りたいです。
|
126
126
|
|
127
127
|
宜しくお願いします。
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
下記は解決後のプログラムです。
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
```c
|
136
|
+
|
137
|
+
#define _CRT_SECURE_NO_WARNINGS
|
138
|
+
|
139
|
+
#define N 128
|
140
|
+
|
141
|
+
#define A 128
|
142
|
+
|
143
|
+
#define _CRT_SECURE_NO_WARNINGS
|
144
|
+
|
145
|
+
#define N 128
|
146
|
+
|
147
|
+
#define A 128
|
148
|
+
|
149
|
+
#include <stdio.h>
|
150
|
+
|
151
|
+
#include <string.h>
|
152
|
+
|
153
|
+
#include <ctype.h>
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
void put_strary2(const char s[][A], int n)
|
160
|
+
|
161
|
+
{
|
162
|
+
|
163
|
+
int i, j, l, m;
|
164
|
+
|
165
|
+
/*-入力-*/
|
166
|
+
|
167
|
+
for (i = 0; i < n; i++) {
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
int j = 0;
|
172
|
+
|
173
|
+
int k = 0;
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
scanf("%s", s[i]);
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
while (k < 5) {
|
182
|
+
|
183
|
+
if (s[i][j] == '$') {
|
184
|
+
|
185
|
+
k++;
|
186
|
+
|
187
|
+
j++;
|
188
|
+
|
189
|
+
}
|
190
|
+
|
191
|
+
else
|
192
|
+
|
193
|
+
break;
|
194
|
+
|
195
|
+
}
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
if (k == 5)
|
200
|
+
|
201
|
+
break;
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
}
|
206
|
+
|
207
|
+
/*-出力-*/
|
208
|
+
|
209
|
+
printf("%d\n", i);
|
210
|
+
|
211
|
+
/*上の行はiに代入されてる値を調べるために追加しました。*/
|
212
|
+
|
213
|
+
for (l = 0; l < i; l++) {
|
214
|
+
|
215
|
+
for (m = 0; s[l][m] != '\0'; m++) {
|
216
|
+
|
217
|
+
printf("%c", s[l][m]);
|
218
|
+
|
219
|
+
}
|
220
|
+
|
221
|
+
putchar('\n');
|
222
|
+
|
223
|
+
}
|
224
|
+
|
225
|
+
}
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
int main(void)
|
232
|
+
|
233
|
+
{
|
234
|
+
|
235
|
+
char cs[N][A] = { "0" };
|
236
|
+
|
237
|
+
printf("文字列を入力\n");
|
238
|
+
|
239
|
+
put_strary2(cs, N);
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
}
|
244
|
+
|
245
|
+
```
|
2
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -106,7 +106,7 @@
|
|
106
106
|
|
107
107
|
{
|
108
108
|
|
109
|
-
char cs[][A] = { "0" };
|
109
|
+
char cs[N][A] = { "0" };
|
110
110
|
|
111
111
|
printf("文字列を入力\n");
|
112
112
|
|
1
誤字
test
CHANGED
File without changes
|
test
CHANGED
@@ -122,6 +122,6 @@
|
|
122
122
|
|
123
123
|
そこで試しに、入力が終了したところでiの値を確認したところ0となっていました。
|
124
124
|
|
125
|
-
なぜiになってしまうのか理由が知りたいです。
|
125
|
+
なぜi=0になってしまうのか理由が知りたいです。
|
126
126
|
|
127
127
|
宜しくお願いします。
|