algorithms 백준 (BOJ)

[BOJ]백준 11720번: 숫자의 합 (baekjoon 11720)

(BOJ)백준 11720 - 11720번: 숫자의 합

11720번: 숫자의 합

코드

import java.io.*;

public class B11720 {
    static int N, ans = 0;
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        N = Integer.parseInt(br.readLine());
        String in = br.readLine();
        for (int i = 0; i < in.length(); i++) {
            ans += in.charAt(i) - 48;
        }
        bw.write(ans + "\n");bw.flush();
        bw.close();
    }
}

설명

Copied to clipboard