回答編集履歴

1

コードの改善

2020/09/02 13:43

投稿

kazuma-s
kazuma-s

スコア8224

test CHANGED
@@ -66,15 +66,11 @@
66
66
 
67
67
  if (!isalpha(c)) continue;
68
68
 
69
- int count = 0;
69
+ int j = i;
70
70
 
71
- for (int j = 0; j < i; j++)
71
+ while (--j >= 0 && c != tolower((unsigned char)city[j])) ;
72
72
 
73
- if (c == tolower((unsigned char)city[j]))
74
-
75
- count++;
76
-
77
- if (count != 0) continue;
73
+ if (j >= 0) continue;
78
74
 
79
75
  if (string > base) *string++ = ',';
80
76
 
@@ -82,7 +78,7 @@
82
78
 
83
79
  *string++ = ':';
84
80
 
85
- for (int j = i; j < n; j++)
81
+ for (j = i; j < n; j++)
86
82
 
87
83
  if (c == tolower((unsigned char)city[j]))
88
84