2.6 import java.util.Scanner; public class test { public static void main(String[] args) { Scanner Hy=new Scanner(System.in); String Hyper; System.out.println("请输入一个0-1000的整数来求整数各位数的和"); Hyper = Hy.nextLine(); if(Integer.valueOf(Hyper) <= 1000) { int a = 0; for (int i = 0; i < Hyper.length(); i++) { a = a + Integer.valueOf(Hyper.substring(i, i + 1)); } System.out.println(a); }*/ } }
转载于:https://www.cnblogs.com/Archon-Cty/p/7535027.html