Created
May 2, 2020 06:50
-
-
Save DongguemYoo/1b8e8fcfe441b65e92efedd75b1a00c8 to your computer and use it in GitHub Desktop.
코딩테스트 연습 수박수박수박수?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//내가 푼 방식 | |
public class Solution { | |
public string solution(int n) { | |
string answer = ""; | |
string pattern1 = "수"; | |
string pattern2 = "박"; | |
for(int i=0;i<n;i++) | |
{ | |
if(i%2==0) | |
answer+=pattern1; | |
else | |
answer+=pattern2; | |
} | |
return answer; | |
} | |
} | |
//다른사람이 푼 방식 | |
//이항연산자를 사용해서 풀었다!! | |
//나도 이항연산자를 좀 사용하자아~ | |
public class Solution { | |
public string solution(int n) { | |
string answer = ""; | |
for(int i=0;i<n;i++) | |
{ | |
answer+= i%2==0?"수":"박"; | |
} | |
return answer; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment