public static void main(String[] args) { int num = 321; int sum = 0; while (num > 0) { sum = sum + num % 10; num = num / 10; } System.out.println(sum); }
输出量
6
欢迎分享,转载请注明来源:内存溢出
public static void main(String[] args) { int num = 321; int sum = 0; while (num > 0) { sum = sum + num % 10; num = num / 10; } System.out.println(sum); }
输出量
6
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)