程序应该输出:35379
9
输入格式程序应该输出:7583676109608471656473500295825
1
内存限制:256.0MB C/C++时间限制:1.0s Java时间限制:3.0s Python时间限制:5.0s
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String str = sc.next();
char[] ch = str.toCharArray();
while (true) {
int num = 0;
for (int i = 0; i < ch.length; i++) {
num += (ch[i] - '0');
}
str = num + "";
if (str.length() == 1) {
System.out.println(str);
break;
}
ch = str.toCharArray();
}
}
}



