알고리즘 풀이

Level 1 수박수박수박수박수박수?

bedst 2017. 3. 30. 17:39

/* 

 * 출처 : 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));

}

}