質問編集履歴
3
間違いの訂正
test
CHANGED
File without changes
|
test
CHANGED
@@ -260,7 +260,7 @@
|
|
260
260
|
|
261
261
|
|
262
262
|
|
263
|
-
answer[i] += (words[i][j] -
|
263
|
+
answer[i] += (words[i][j] - 'a' - 1); //文字を数値に変換
|
264
264
|
|
265
265
|
|
266
266
|
|
2
間違いの訂正
test
CHANGED
File without changes
|
test
CHANGED
@@ -215,3 +215,75 @@
|
|
215
215
|
}
|
216
216
|
|
217
217
|
```
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
修正版
|
222
|
+
|
223
|
+
```c
|
224
|
+
|
225
|
+
#include <stddef.h>
|
226
|
+
|
227
|
+
#include <stdlib.h> //malloc
|
228
|
+
|
229
|
+
#include <string.h> //strlen
|
230
|
+
|
231
|
+
#include <ctype.h> //isalpha
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
const int* name_value(size_t n, const char *const words[n]) {
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
size_t i;
|
240
|
+
|
241
|
+
int* answer = calloc(n,sizeof(int) );
|
242
|
+
|
243
|
+
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
for(i = 0; i < n; i++)
|
248
|
+
|
249
|
+
{
|
250
|
+
|
251
|
+
int l = strlen(words[i]);
|
252
|
+
|
253
|
+
for(size_t j = 0; j < (size_t)l; j++)
|
254
|
+
|
255
|
+
{
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
if (!isalpha(words[i][j]))continue; //空白だったらスキップ
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
answer[i] += (words[i][j] - 96); //文字を数値に変換
|
264
|
+
|
265
|
+
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
}
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
answer[i] *= (i + 1);
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
}
|
280
|
+
|
281
|
+
|
282
|
+
|
283
|
+
|
284
|
+
|
285
|
+
return answer;
|
286
|
+
|
287
|
+
}
|
288
|
+
|
289
|
+
```
|
1
間違いの訂正
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
codewarsというサイト内で問題を解いています。
|
1
|
+
codewarsというサイト内で問題を解いています。https://www.codewars.com/kata/598d91785d4ce3ec4f000018/train/c
|
2
2
|
|
3
3
|
文字列を与えられ、アルファベットのそれぞれの文字が値を持つとして、(a = 1, b = 2, c = 3 ....z = 26)
|
4
4
|
|