Skip to content

Commit b5b9d64

Browse files
authored
Update README_EN.md
1 parent a33c203 commit b5b9d64

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

solution/0000-0099/0012.Integer to Roman/README_EN.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -300,26 +300,26 @@ class Solution {
300300

301301
#### C
302302

303-
```C
303+
```c
304+
static const char* cs[] = {
305+
"M", "CM", "D", "CD", "C", "XC",
306+
"L", "XL", "X", "IX", "V", "IV", "I"};
304307

305-
char* intToRoman(int num) {
306-
static char res[20];
307-
res[0] = '\0';
308-
309-
int vals[] = {1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1};
310-
char* syms[] = {"M", "CM", "D", "CD", "C", "XC", "L",
311-
"XL", "X", "IX", "V", "IV", "I"};
308+
static const int vs[] = {
309+
1000, 900, 500, 400, 100, 90,
310+
50, 40, 10, 9, 5, 4, 1};
312311

313-
for (int i = 0; i < 13; i++) {
314-
while (num >= vals[i]) {
315-
strcat(res, syms[i]);
316-
num -= vals[i];
312+
char* intToRoman(int num) {
313+
static char ans[20];
314+
ans[0] = '\0';
315+
for (int i = 0; i < 13; ++i) {
316+
while (num >= vs[i]) {
317+
num -= vs[i];
318+
strcat(ans, cs[i]);
317319
}
318320
}
319-
return res;
321+
return ans;
320322
}
321-
322-
323323
```
324324

325325
<!-- tabs:end -->

0 commit comments

Comments
 (0)