- 1. replace(), Integer.ParseInt 사용
public static void main(String[] args) {
Main T = new Main();
Scanner sc = new Scanner(System.in);
int i = sc.nextInt();
String str = sc.next();
T.solution(str, i);
}
public String solution (String str, int i){
String answer = "";
for (int j = 0; j < i; j++) {
String sub = str.substring(0, 7).replace('#', '1').replace('*', '0');
int toChar = Integer.parseInt(sub, 2);// 2진수를 10진수로 변환
answer += (char) toChar; // 10진수를 아스키코드를 활용하여 문자로 변환
str = str.substring(7);
}
System.out.println(answer);
return answer;
}
}