Created
May 3, 2020 08:58
-
-
Save DongguemYoo/8e4aa542299f2680cff31b93cf5ebdeb 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 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