标签:nbsp images 输入 ima int void blog ring imp
import java.math.BigInteger;
import java.util.Scanner;
//信1605-2 20163434 刘冰
public class test {
int num[];
String number;
int number2;
int n=10;
public void weiShu(){
System.out.println("输入正整数:");
num=new int[32];
Scanner scanner=new Scanner(System.in);
number=scanner.nextLine();
int number2;
number2=Integer.parseInt(number);
System.out.println("正整数为"+number.length()+"位数");
for(int i=0;i<number.length();i++)
{
number2=Integer.parseInt(number);
num[i]=number2%n/(n/10);
n=n*10;
}
}
public void shuChu()
{
int sum=0;
for(int i=0;i<number.length();i++)
{
sum=sum+num[i];
}
System.out.println("各位数之和为"+sum);
for(int i=0;i<number.length();i++)
{
System.out.println("各位数为:"+num[i]);
}
}
public static void main(String[] args) {
test s=new test();
s.weiShu();
s.shuChu();
}
标签:nbsp images 输入 ima int void blog ring imp
原文地址:http://www.cnblogs.com/bangandwolf/p/7645690.html