回答編集履歴

2

コード修正

2020/10/25 11:43

投稿

SHOMI
SHOMI

スコア4079

test CHANGED
@@ -8,9 +8,7 @@
8
8
 
9
9
 
10
10
 
11
- - 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' };
11
+ 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' };
12
-
13
- + 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' };
14
12
 
15
13
  char str[128];
16
14
 
@@ -20,7 +18,7 @@
20
18
 
21
19
  - int count = 0;
22
20
 
23
- + int count[27] = {0};
21
+ + int count[26] = {0};
24
22
 
25
23
  scanf("%s", &str);
26
24
 

1

コード修正

2020/10/25 11:43

投稿

SHOMI
SHOMI

スコア4079

test CHANGED
@@ -18,7 +18,9 @@
18
18
 
19
19
  int j = 0;
20
20
 
21
- int count = 0;
21
+ - int count = 0;
22
+
23
+ + int count[27] = {0};
22
24
 
23
25
  scanf("%s", &str);
24
26
 
@@ -34,11 +36,13 @@
34
36
 
35
37
  if (str[i] == alf[j]) {
36
38
 
37
- count++;
39
+ - count++;
40
+
41
+ + count[j]++;
38
42
 
39
43
  - printf("%sが%d個\n", str[i], count);
40
44
 
41
- + printf("%cが%d個\n", str[i], count);
45
+ + printf("%cが%d個\n", str[i], count[j]);
42
46
 
43
47
  }
44
48