백준 알고리즘 - 11720 (숫자의 합)

aladin·2020년 8월 22일
0

백준알고리즘

목록 보기
13/18

문제

I.O

코드 및 해석

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Boj_11720 {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int N = Integer.parseInt(br.readLine());
		int sum = 0;
		String str = br.readLine();
		
		for(int i = 0 ; i < str.length() ; i++) {
			sum += str.charAt(i) - '0';
		}
		System.out.println(sum);
	}
}

문제 및 사진출처

출처 - 백준 알고리즘_11720번

profile
컴공과 대학생의 개발노트

0개의 댓글