题解 | #数位之和#
数位之和
http://www.nowcoder.com/practice/5e85cc26475449648e668aa98e92d05b
import java.util.Scanner; public class Main{ public static void main(String[]args){ Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int sum=0; while(a!=0){ sum = sum+a%10; a = a/10; } System.out.println(sum); } }