Notice
Recent Posts
Recent Comments
Link
Dev.baelanche
[백준 3054] 피터팬 프레임 본문
반응형
단순구현 문제라 정말 막풀었다.
변수 이름이라도 그나마 알아볼수 있게 서술했다;;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String s = sc.next();
int len = (s.length() * 5) - (s.length() - 1);
drawSideLine(len);
drawInnerLine(len);
drawMiddleLine(len, s);
drawInnerLine(len);
drawSideLine(len);
}
public static void drawSideLine(int len) {
int sideLine = 0;
for(int i=1; i<=len; i++) {
if((i-3)%4==0) {
sideLine++;
if(sideLine == 3) {
System.out.print("*");
sideLine = 0;
continue;
}
System.out.print("#");
continue;
}
System.out.print(".");
}
System.out.println();
}
public static void drawInnerLine(int len) {
int innerLine = 0;
for(int i=1; i<=len; i++) {
if(i%2==0) {
innerLine++;
if(innerLine >= 5) {
System.out.print("*");
if(innerLine == 6)
innerLine = 0;
continue;
}
System.out.print("#");
continue;
}
System.out.print(".");
}
System.out.println();
}
public static void drawMiddleLine(int len, String s) {
int k = 0;
int str = 0;
int condition = 3;
int middleLine = 0;
for(int i=1; i<=len; i++) {
if(i%2!=0) {
str++;
if(str == 2) {
System.out.print(s.charAt(k));
k++;
middleLine++;
str = 0;
continue;
}
if(condition <= s.length() && (middleLine == 2 || middleLine == 3)) {
System.out.print("*");
if(middleLine == 3) {
middleLine = 0;
condition += 3;
}
continue;
}
System.out.print("#");
continue;
}
System.out.print(".");
}
System.out.println();
}
}
반응형
'Data Structure & Algorithm > PS - JAVA' 카테고리의 다른 글
[백준 2823] 유턴 싫어 (2) | 2019.04.27 |
---|---|
[백준 9324] 진짜 메세지 (0) | 2019.04.27 |
[백준 2810] 컵홀더 (0) | 2019.04.27 |
[백준 1773] 폭죽쇼 (0) | 2019.04.27 |
[백준 12813] 이진수 연산 (0) | 2019.04.27 |
Comments