回答編集履歴

3

strlen を変数化

2020/02/06 04:18

投稿

jimbe
jimbe

スコア12648

test CHANGED
@@ -28,13 +28,17 @@
28
28
 
29
29
  int a1[SIZE]={0};
30
30
 
31
+ int l1=strlen(s1);
32
+
31
- for(int i=0;i<strlen(s1);i++) a1[s1[i]-'a']=1;
33
+ for(int i=0;i<l1;i++) a1[s1[i]-'a']=1;
32
34
 
33
35
 
34
36
 
35
37
  int a2[SIZE]={0};
36
38
 
39
+ int l2=strlen(s2);
40
+
37
- for(int i=0;i<strlen(s2);i++) a2[s2[i]-'a']++;
41
+ for(int i=0;i<l2;i++) a2[s2[i]-'a']++;
38
42
 
39
43
 
40
44
 

2

追加

2020/02/06 04:18

投稿

jimbe
jimbe

スコア12648

test CHANGED
@@ -1,4 +1,4 @@
1
- s1="catfood" s2="carroot" の時は幾つになるでしょう.
1
+ そのコードでは s1="catfood" s2="carroot" の時は幾つになるでしょう.
2
2
 
3
3
 
4
4
 

1

追加

2020/02/05 20:03

投稿

jimbe
jimbe

スコア12648

test CHANGED
@@ -1,3 +1,7 @@
1
+ s1="catfood" s2="carroot" の時は幾つになるでしょう.
2
+
3
+
4
+
1
5
  100000文字は試していません.
2
6
 
3
7
  ```c