Skip to content

Commit

Permalink
Baekjoon #1212 8진수 2진수
Browse files Browse the repository at this point in the history
Baekjoon #1212 8진수 2진수
Merge pull request #1 from allrightDJ0108/macDev
  • Loading branch information
allrightDJ0108 committed Oct 16, 2023
2 parents 3db887d + 1222951 commit 350ff84
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
Binary file not shown.
30 changes: 30 additions & 0 deletions CodingTestStudy1.0/src/Implementation/Problem1212.java
@@ -0,0 +1,30 @@
package Implementation;

import java.io.*;

public class Problem1212 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String str = br.readLine();
String[] b = {"000", "001", "010", "011", "100", "101", "110", "111"};

StringBuilder sb = new StringBuilder();
for (int i=0; i<str.length(); i++){
int a = str.charAt(i) - '0';
//System.out.println(a);
sb.append(b[a]);
}

if (str.equals("0")) System.out.println(str);
else {
while (sb.charAt(0) == '0'){
sb = new StringBuilder(sb.substring(1));
}
System.out.println(sb);
}

}

}


0 comments on commit 350ff84

Please sign in to comment.