강의

멘토링

커뮤니티

Inflearn Community Q&A

somlh0381's profile image
somlh0381

asked

Introduction to Java Algorithm Problem Solving: Coding Test Preparation

12. Cipher (replace(), parseInt(string, 2))

왜 컴파일 에러가 뜰까요 .. ㅠ

Written on

·

255

0

public class Main{

public String solution(int num, String str) {

String answer = "";

for (int i=0; i<num; i++ ) {

String tmp = str.substring(0, 7).replace('#', '1').replace('*', '0');

answer += Character.toString(Integer.valueOf(tmp, 2));

str = str.substring(7);

}

return answer;

}

public static void main(String[] args) {

Main T = new Main();

Scanner scr = new Scanner(System.in);

int num = scr.nextInt();

String str = scr.next();

System.out.println(T.solution(num, str));

}

}

java코테 준비 같이 해요!

Answer 1

0

import java.util.Scanner;
somlh0381's profile image
somlh0381

asked

Ask a question