参考代码:
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); while(scanner.hasNext()) { long in = scanner.nextLong(); System.out.println(p(in)); } } public static int p(long x) { int res = 0; while(x != 0) { res += x % 10; x /= 10; } return res; } }
0.0分
5 人评分
2005年春浙江省计算机等级考试二级C 编程题(3) (C语言代码)浏览:387 |
WU-蓝桥杯算法提高VIP-企业奖金发放 (C++代码)浏览:1162 |
校门外的树 (C语言代码)浏览:692 |
C语言程序设计教程(第三版)课后习题8.6 (C语言代码)浏览:562 |
星期判断机 (C语言代码)浏览:859 |
C二级辅导-求偶数和 (C语言代码)浏览:671 |
时间转换 (C语言代码)浏览:624 |
盐水的故事 (C语言代码)浏览:1524 |
C语言程序设计教程(第三版)课后习题8.6 (C语言代码)浏览:761 |
整数分类问题 为什么输出总是数字8啊浏览:442 |