比较简单,奉上java满分代码
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String number = scanner.nextLine();
scanner.close();
int sum = 0;
for(int i = 0; i < number.length(); i++){
sum += number.charAt(i) - '0';
}
System.out.println(sum);
}
}