-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProblem186.java
More file actions
36 lines (32 loc) · 832 Bytes
/
Copy pathProblem186.java
File metadata and controls
36 lines (32 loc) · 832 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package hard.method;
import java.util.Scanner;
// 정수의 입력값이 0~9까지 숫자중 각각 한번씩만 사용되었는지 확인하는 함수작성
public class Problem186 {
public static void main(String[] args) {
Scanner stdIn = new Scanner(System.in);
System.out.print("Enter the number : ");
int num = stdIn.nextInt(); // 152627389 => return false
if(checkUseOne(num))
System.out.println("True");
else
System.out.println("False");
stdIn.close();
}
static boolean checkUseOne(int n) {
boolean check = true;
String num = String.valueOf(n);
int length = num.length();
for(int i=0; i<length; i++) {
char val = num.charAt(i);
for(int j=0; j<length; j++) {
if(i == j)
continue;
else {
if(val == num.charAt(j))
check = false;
}
}
}
return check;
}
}