Love丶FFC's Blog
给定一个十进制整数n,输出n的各位数字之和。
输入一个整数n。
输出一个整数,表示答案。
20151220
13
20151220的各位数字之和为2+0+1+5+1+2+2+0=13。
所有评测用例满足:0 ≤ n ≤ 1000000000。
1.通过字符串函数获取各位,然后强制类型转换相加。
package CCF_CSP; import java.util.Scanner; public class _20151201_100point { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); //输入的数字 int sum = 0; for(int i=0;i<(n+"").length();i++) //获取n的位数 { sum+=Integer.parseInt((n+"").charAt(i)+""); //转换为字符串后提取其中字符再强制类型转换 } System.out.println(sum); } }
Gealpaste
Furthermore, patients who stopped or switched from an AI had approximately double the rate of arthritis ICD codes of patients who stopped or switched from an SERM Table 4 cialis vs viagra
intuido
71 d, J 8 Hz, 1H, 7 cialis without prescription