jmu-Java-01入门-取数字浮点数(简便版)

  • Post author:
  • Post category:java


import java.util.*;

public class Main {

	public static void main(String args[]) {
		Scanner in =new Scanner(System.in);
		while(true){
			String s=in.next();
			int sum=0;
			for (int j = 0; j < s.length(); j++) {
				int temp=Character.getNumericValue(s.charAt(j));
				if (temp!=-1) {
					sum+=temp;
				}
			}
			System.out.println(sum);
		}
	}
}



版权声明:本文为m0_55971510原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。