웅재의 코딩세상
[프로그래머스] 9로 나눈 나머지 본문
- 풀이
#include <string>
#include <vector>
using namespace std;
int solution(string number) {
int answer = 0;
for(int i=0; i<number.size(); i++){
answer += number[i]-'0';
}
return answer % 9;
}
반응형
'코딩테스트 > 프로그래머스 - LV 0' 카테고리의 다른 글
[프로그래머스] 접미사 배열 (0) | 2024.01.30 |
---|---|
[프로그래머스] 문자열 여러 번 뒤집기 (0) | 2024.01.30 |
[프로그래머스] 주사위 게임 3 (0) | 2024.01.30 |
[프로그래머스] 간단한 논리 연산 (0) | 2024.01.30 |
[프로그래머스] 0 떼기 (1) | 2024.01.29 |