[백준] P11720

동민·2021년 3월 11일
import java.util.Scanner;

public class P11720 {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		char[] arr;
		int n = sc.nextInt();
		String s = sc.next();
		
		arr = new char[n];
		
		for(int i = 0; i < arr.length; i++) {
			arr[i] = s.charAt(i);
		}
		
		int temp = 0;
		int sum = 0;
		for(int i = 0; i < arr.length; i++) {
			temp = arr[i];
			sum += temp - 48;
		}
		
		System.out.println(sum);
		
		sc.close();
	}

}
profile
BE Developer

0개의 댓글