공부/Java
1,2,3 숫자를 입력받아 가,나,다,가가,가나... 로 반환해주는 함수(가나다 번호 자동 생성)
딸기버블티
2022. 9. 26. 16:33
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
public static String getNumberToString(int number, String[] strArr) {
String returnValue = "";
int length = strArr.length;
while (number >= length) {
int val = number / length - 1;
int index = number % length;
returnValue = strArr[index] + returnValue;
number = val;
}
returnValue = strArr[number] + returnValue;
return returnValue;
}
|
cs |
strArr 이 가,나,다 일때
입력값 출력값
1 가
2 나
3 다
4 가가
5 가나
6 가다
7 나가
.
.
.
가가가