回答編集履歴
2
コード修正
answer
CHANGED
@@ -3,13 +3,12 @@
|
|
3
3
|
#include <string.h>
|
4
4
|
int main(void) {
|
5
5
|
|
6
|
-
|
6
|
+
char alf[26] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };
|
7
|
-
+ char alf[27] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };
|
8
7
|
char str[128];
|
9
8
|
int i = 0;
|
10
9
|
int j = 0;
|
11
10
|
- int count = 0;
|
12
|
-
+ int count[
|
11
|
+
+ int count[26] = {0};
|
13
12
|
scanf("%s", &str);
|
14
13
|
while (str[i] != '\0') {
|
15
14
|
printf("%c ", str[i]);
|
1
コード修正
answer
CHANGED
@@ -8,7 +8,8 @@
|
|
8
8
|
char str[128];
|
9
9
|
int i = 0;
|
10
10
|
int j = 0;
|
11
|
-
int count = 0;
|
11
|
+
- int count = 0;
|
12
|
+
+ int count[27] = {0};
|
12
13
|
scanf("%s", &str);
|
13
14
|
while (str[i] != '\0') {
|
14
15
|
printf("%c ", str[i]);
|
@@ -16,9 +17,10 @@
|
|
16
17
|
- for (alf[j] = 0; j <= 26; j++) {
|
17
18
|
+ for (j = 0; j < 26; j++) {
|
18
19
|
if (str[i] == alf[j]) {
|
19
|
-
count++;
|
20
|
+
- count++;
|
21
|
+
+ count[j]++;
|
20
22
|
- printf("%sが%d個\n", str[i], count);
|
21
|
-
+ printf("%cが%d個\n", str[i], count);
|
23
|
+
+ printf("%cが%d個\n", str[i], count[j]);
|
22
24
|
}
|
23
25
|
}
|
24
26
|
+ i++;
|