回答編集履歴
1
コードの改善
answer
CHANGED
@@ -32,15 +32,13 @@
|
|
32
32
|
for (int i = 0; i < n; i++) {
|
33
33
|
int c = tolower((unsigned char)city[i]);
|
34
34
|
if (!isalpha(c)) continue;
|
35
|
-
int
|
35
|
+
int j = i;
|
36
|
-
for (int j = 0; j < i; j++)
|
37
|
-
|
36
|
+
while (--j >= 0 && c != tolower((unsigned char)city[j])) ;
|
38
|
-
count++;
|
39
|
-
if (
|
37
|
+
if (j >= 0) continue;
|
40
38
|
if (string > base) *string++ = ',';
|
41
39
|
*string++ = c;
|
42
40
|
*string++ = ':';
|
43
|
-
for (
|
41
|
+
for (j = i; j < n; j++)
|
44
42
|
if (c == tolower((unsigned char)city[j]))
|
45
43
|
*string++ = '*';
|
46
44
|
}
|