解题思路:
注意事项:
参考代码:
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (sc.hasNext()) { int sum = 0; String n = sc.next(); for (int i = 0; i < n.length(); i++) sum += n.charAt(i) - '0'; System.out.println(sum); } } }
0.0分
8 人评分