/* 

 * 출처 : http://tryhelloworld.co.kr/challenge_codes/109

 */

public class WaterMelon {

public String watermelon(int n){

String str="";

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

if(i%2 == 0){

str+="수";

}else{

str+="박";

}

}

return str;

}


// 실행을 위한 테스트코드입니다.

public static void  main(String[] args){

WaterMelon wm = new WaterMelon();

System.out.println("n이 3인 경우: " + wm.watermelon(3));

System.out.println("n이 4인 경우: " + wm.watermelon(4));

}

}



'알고리즘 풀이' 카테고리의 다른 글

Codility ] Lesson2 : 1. CyclicRotation  (0) 2018.05.01
Codility ] Lesson1 : BinaryGap  (0) 2018.04.30
Level 2 2016년  (0) 2017.03.30
Level 2 최솟값 만들기  (0) 2017.03.30
Level 1 행렬의 덧셈  (0) 2017.03.30

+ Recent posts