Skip to content

Instantly share code, notes, and snippets.

@DongguemYoo
Created May 22, 2020 05:47
Show Gist options
  • Save DongguemYoo/6fb2b22e2b8798d6aa71b0207f067c8c to your computer and use it in GitHub Desktop.
Save DongguemYoo/6fb2b22e2b8798d6aa71b0207f067c8c to your computer and use it in GitHub Desktop.
코딩테스트 연습 - 가운데 글자 가져오기.cs
음...이거는뭐 설명도 필요없는듯
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