728x90
https://school.programmers.co.kr/learn/courses/30/lessons/181914
소스코드
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
public class Solution
{
public int solution(string number)
{
int answer = 0;
for (int i = 0; i < number.Length; i++)
answer += number[i] - '0';
return answer % 9;
// return number.Select(s => s - '0').Sum() % 9;
}
}
728x90
'코딩공부 > 프로그래머스' 카테고리의 다른 글
[프로그래머스]Lv.0 배열 만들기 5 C# (0) | 2023.06.07 |
---|---|
[프로그래머스]Lv.0 문자열 여러 번 뒤집기 C# (Aarray.Reverse) (0) | 2023.06.07 |
[프로그래머스]Lv.0 글자 이어 붙여 문자열 만들기 C# (0) | 2023.06.07 |
[프로그래머스]Lv.0 주사위 게임3 C# (0) | 2023.06.07 |
[프로그래머스]Lv.0 간단한 논리 연산 C# (0) | 2023.06.07 |