解题思路:
注意事项:
参考代码:
import java.math.BigInteger; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); //输入这一个数 BigInteger a = sc.nextBigInteger(); int b = tm(a); System.out.println(b); } public static int tm(BigInteger a){ BigInteger sum = new BigInteger("0"); BigInteger b = new BigInteger("10"); BigInteger D = new BigInteger("0"); while (a.compareTo(D) > 0) { BigInteger c = a.mod(b); a = a.divide(b); sum = sum.add(c); } int g = sum.intValue(); if(g >= 10){ return tm(sum); }else{ return g; } } }
0.0分
0 人评分
简单的a+b (C语言代码)浏览:530 |
C语言程序设计教程(第三版)课后习题5.8 (C语言代码)浏览:572 |
C语言程序设计教程(第三版)课后习题6.9 (C语言代码)浏览:543 |
2003年秋浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:751 |
简单的a+b (C语言代码)浏览:573 |
WU-小九九 (C++代码)浏览:1684 |
【绝对值排序】 (C语言代码)浏览:821 |
C语言程序设计教程(第三版)课后习题6.6 (C语言代码)浏览:349 |
C语言程序设计教程(第三版)课后习题8.5 (C语言代码)浏览:577 |
DNA (C语言描述,蓝桥杯)浏览:1555 |