标签:style div stat scan print main nbsp ring add
数字具体的和
public static void main(String[] args) { while (true) { System.out.println("请输入一个数字"); Scanner sc = new Scanner(System.in); long b = sc.nextLong(); // int x = 121; // int b = x%10000; // int qian = b / 1000; // int bai = b % 1000 / 100; // int shi = b % 1000 % 100 / 10; // int ge = b % 1000 % 100 % 10; long ge = b % 10; long shi = b / 10 % 10; long bai = b / 100 % 10; long qian = b/ 1000 % 10; long add = qian + bai + shi + ge; //System.out.println("四位数的和是" + (qian + bai + shi + ge) + "\n"); System.out.println("后四位数的和是" +add+ "\n"); } } }
标签:style div stat scan print main nbsp ring add
原文地址:https://www.cnblogs.com/dupeilin/p/12835114.html