슈콩

COS PRO 1급 JAVA 전광판 문구 출력 본문

카테고리 없음

COS PRO 1급 JAVA 전광판 문구 출력

shukong 2025. 12. 18. 22:59

 

 

[소스 코드]

import java.util.*;

class Main {
    public String solution(String phrases, int second) {
        // 여기에 코드를 작성해주세요.
        int length = 14;
				String answer = "";
				StringBuilder sb = new StringBuilder();
				for(int i=0;i<length;i++) sb.append("_");
				sb.append(phrases);
				for(int i=0;i<length;i++) sb.append("_");
        int cycle = length + phrases.length();
				int pos = second % cycle;
				answer = sb.substring(pos,pos+phrases.length());
				return answer;
    }
}