SWEA 2058 자릿수 더하기

Jmnote (토론 | 기여)님의 2018년 4월 20일 (금) 19:39 판 (새 문서: ==개요== ;SWEA-2058 자릿수 더하기 {{소스헤더|입력}} <source lang='text'> 6789 </source> {{소스헤더|출력}} <source lang='text'> 30 </source> ==C++== <source lang='...)
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

1 개요

SWEA-2058 자릿수 더하기
입력
6789
출력
30

2 C++

#include <iostream>

using namespace std;

int main() {
    int N;
    cin >> N;
    int a, b, i;
    int sum = 0;
    for(i=0; i<4; i++) {
        a = N % 10;
        N = N / 10;
        sum += a;
    }
    cout << sum << endl;
}

3 Java

4 같이 보기

5 참고

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}