题解 | #The Biggest Water Problem#
The Biggest Water Problem
http://www.nowcoder.com/practice/435aa556e093463891f6da7d322140a4
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int res = 0;
while(true) {
int sum = 0;
while (n > 0) {
sum += n % 10;
n /= 10;
}
res = sum;
if (res < 10) break;
n = res;
}
System.out.println(res);
}
}
查看15道真题和解析