코딩테스트 연습 - [PCCE 기출문제] 3번 / 수 나누기 | 프로그래머스 스쿨
프로그래머스
SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프
programmers.co.kr
C++
#include <iostream>
using namespace std;
int main(void) {
int number;
cin >> number;
int answer = 0;
for(int i=0; i<10; i++){
answer += number % 100;
number /= 100;
}
cout << answer << endl;
return 0;
}
자바
import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int number = sc.nextInt();
int answer = 0;
for(int i=0; i<10; i++){
answer += number % 100;
number /= 100;
}
System.out.println(answer);
}
}
python
number = int(input())
answer = 0
for i in range(10):
answer += number % 100
number //= 100
print(answer)
'Portpolio > codingtest' 카테고리의 다른 글
프로그래머스 Lv3. 네트워크 풀이 (0) | 2025.03.19 |
---|---|
프로그래머스 커피 심부름 풀이 (0) | 2025.02.26 |
프로그래머스 각도 합치기 풀이 (0) | 2025.02.26 |
프로그래머스 문자 출력 풀이 (0) | 2025.02.26 |
프로그래머스 문자열을 정수로 변환하기 풀이 (1) | 2025.02.23 |
댓글