Skip to content

Instantly share code, notes, and snippets.

@DongguemYoo
Created May 3, 2020 08:58
Show Gist options
  • Save DongguemYoo/8e4aa542299f2680cff31b93cf5ebdeb to your computer and use it in GitHub Desktop.
Save DongguemYoo/8e4aa542299f2680cff31b93cf5ebdeb to your computer and use it in GitHub Desktop.
코딩테스트 연습문제 자릿수 더하기.cs
public int solution(int n)
{
int answer = 0;
char[] s = n.ToString().ToCharArray();
for (int i = 0; i < s.Length; i++)
{
answer += int.Parse(s[i].ToString());
}
return answer;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment