質問編集履歴
1
文字列比較にstrcmpを使いました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -27,7 +27,7 @@
|
|
27
27
|
```C
|
28
28
|
#include <stdio.h>
|
29
29
|
#include <stdlib.h>
|
30
|
-
|
30
|
+
#include <string.h>
|
31
31
|
int main(void)
|
32
32
|
{
|
33
33
|
//n人の名前s_1,...,s_n
|
@@ -53,7 +53,7 @@
|
|
53
53
|
int damage = 0;
|
54
54
|
for (int i = 0; i < n; i++) {
|
55
55
|
int j = 0;
|
56
|
-
if (s[i]
|
56
|
+
if (strcmp(s[i], p_a[j][0]) == 0) { //ここが正しく動作しないです。
|
57
57
|
damage += atoi(p_a[j][1]);
|
58
58
|
printf("%s %d\n", p_a[j][0], damage);
|
59
59
|
} else {
|
@@ -63,6 +63,7 @@
|
|
63
63
|
j++;
|
64
64
|
}
|
65
65
|
}
|
66
|
+
|
66
67
|
```
|
67
68
|
|
68
69
|
### 試したこと
|