4321 - 정수의 각 자리 숫자들의 합계

Time Limit: 1s Memory Limit: 128MB

Submissions: 904 Solved: 629
Description

정수 N (0~1,000)를 표현하는 각 자리의 숫자들의 합계를 구하는 프로그램을 작성하세요. 예를 들어 932 정수의 각 자리 숫자들의 합계는 9+3+2=14 입니다. 

Write a program that reads an integer N between 0 and 1000 and adds all the digits in the integer. For example, if an integer is 932, the sum of all its digits is 14. 

Input

* Line 1 : 단일 정수 N (0~1,000)

 

Output

* Line 1 : 단일 정수 (각 자리의 숫자를 더한 값)

 

Sample Input
932
Sample Output
14
Hint

Use the % operator to extract digits, and use the / operator to remove the extracted digit. For instance, 932 % 10 = 2 and 932 / 10 = 93.

Source

JAVA2015 PE2.6