Created
May 22, 2020 05:47
-
-
Save DongguemYoo/6fb2b22e2b8798d6aa71b0207f067c8c to your computer and use it in GitHub Desktop.
코딩테스트 연습 - 가운데 글자 가져오기.cs
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(string s) { | |
string answer = ""; | |
char[] t_c = s.ToCharArray(); | |
if (s.Length % 2 == 1) | |
{ | |
answer = t_c[t_c.Length / 2].ToString(); | |
} | |
else | |
{ | |
answer = t_c[t_c.Length / 2 - 1].ToString() + t_c[t_c.Length / 2].ToString(); | |
/* code */ | |
} | |
return answer; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment