回答編集履歴
2
修正
test
CHANGED
@@ -90,7 +90,7 @@
|
|
90
90
|
|
91
91
|
```
|
92
92
|
|
93
|
-
```
|
93
|
+
```text
|
94
94
|
|
95
95
|
S='take', T='' : invalid
|
96
96
|
|
1
定数化
test
CHANGED
@@ -10,6 +10,16 @@
|
|
10
10
|
|
11
11
|
|
12
12
|
|
13
|
+
/* 衍字最大数 */
|
14
|
+
|
15
|
+
#define SUPERFLUOUS_LETTER_MAX 1
|
16
|
+
|
17
|
+
#define VALID 1
|
18
|
+
|
19
|
+
#define INVALID 0
|
20
|
+
|
21
|
+
|
22
|
+
|
13
23
|
int find(char *s, char *t) {
|
14
24
|
|
15
25
|
int i, ii, j, c;
|
@@ -18,7 +28,7 @@
|
|
18
28
|
|
19
29
|
if(t[i] == s[0]) {
|
20
30
|
|
21
|
-
c = 0; /
|
31
|
+
c = 0; /* 衍字カウンタ */
|
22
32
|
|
23
33
|
for(j=0, ii=i; s[j]!='\0'; ii++) {
|
24
34
|
|
@@ -26,7 +36,7 @@
|
|
26
36
|
|
27
37
|
j ++;
|
28
38
|
|
29
|
-
} else if(++c >
|
39
|
+
} else if(++c > SUPERFLUOUS_LETTER_MAX) {
|
30
40
|
|
31
41
|
break;
|
32
42
|
|
@@ -34,13 +44,13 @@
|
|
34
44
|
|
35
45
|
}
|
36
46
|
|
37
|
-
if(c <=
|
47
|
+
if(c <= SUPERFLUOUS_LETTER_MAX) return VALID;
|
38
48
|
|
39
49
|
}
|
40
50
|
|
41
51
|
}
|
42
52
|
|
43
|
-
return
|
53
|
+
return INVALID;
|
44
54
|
|
45
55
|
}
|
46
56
|
|
@@ -48,7 +58,7 @@
|
|
48
58
|
|
49
59
|
printf("S='%s', T='%s' : %s\n",
|
50
60
|
|
51
|
-
s, t, find(s,t)?"valid":"invalid");
|
61
|
+
s, t, find(s,t)?"valid":"invalid");
|
52
62
|
|
53
63
|
}
|
54
64
|
|