style: format code (#4212)

close #4204
This commit is contained in:
acbin
2023-06-09 18:52:05 +08:00
committed by GitHub
parent ad03086f54
commit 00282efd8b
521 changed files with 5233 additions and 7309 deletions

View File

@ -12,7 +12,7 @@ public class RomanNumeralUtil {
private static final int MIN_VALUE = 1;
private static final int MAX_VALUE = 5999;
//1000-5999
// 1000-5999
private static final String[] RN_M = {
"",
"M",
@ -21,7 +21,7 @@ public class RomanNumeralUtil {
"MMMM",
"MMMMM",
};
//100-900
// 100-900
private static final String[] RN_C = {
"",
"C",
@ -34,7 +34,7 @@ public class RomanNumeralUtil {
"DCCC",
"CM",
};
//10-90
// 10-90
private static final String[] RN_X = {
"",
"X",
@ -47,7 +47,7 @@ public class RomanNumeralUtil {
"LXXX",
"XC",
};
//1-9
// 1-9
private static final String[] RN_I = {
"",
"I",
@ -64,19 +64,10 @@ public class RomanNumeralUtil {
public static String generate(int number) {
if (number < MIN_VALUE || number > MAX_VALUE) {
throw new IllegalArgumentException(
String.format(
"The number must be in the range [%d, %d]",
MIN_VALUE,
MAX_VALUE
)
);
String.format("The number must be in the range [%d, %d]", MIN_VALUE, MAX_VALUE));
}
return (
RN_M[number / 1000] +
RN_C[number % 1000 / 100] +
RN_X[number % 100 / 10] +
RN_I[number % 10]
);
return (RN_M[number / 1000] + RN_C[number % 1000 / 100] + RN_X[number % 100 / 10]
+ RN_I[number % 10]);
}
}