首页 >

用java语言编写计算并输出一个整数各位数字之和? – 网络|

图轻怎么扣图,win7怎么设置电源电量,搜索按钮怎么设置网页用java语言编写计算并输出一个整数各位数字之和? - 网络|用java语言编写计算并输出一个整数各位数字之和

publicclassTestIncreace{

voidTestInc(intn)throwsException{

int[]a=newint[n];

intsum=0;

for(inti=0;i<a.length;i++){

a[i]=n%10;

n=n/10;

sum+=a[i];

}

System.out.println(sum);

}

publicstaticvoidmain(String[]args)throwsException{

try{

TestIncreacet=newTestIncreace();

System.out.println(“请输入您要测试的数据:”);

Scannerinput=newScanner(System.in);

intin=input.nextInt();

t.TestInc(in);//括号内为要测试的数据

}catch(Exceptione){

System.out.println(“非法数字”);

}

}

}


用java语言编写计算并输出一个整数各位数字之和? - 网络|
  • DEA模型测评银行贷款效率,只分析一年的数据可以吗? - 网络|
  • DEA模型测评银行贷款效率,只分析一年的数据可以吗? - 网络| | DEA模型测评银行贷款效率,只分析一年的数据可以吗? - 网络| ...

    用java语言编写计算并输出一个整数各位数字之和? - 网络|
  • 汇编源程序用哪种格式保存? - 网络|
  • 汇编源程序用哪种格式保存? - 网络| | 汇编源程序用哪种格式保存? - 网络| ...

    用java语言编写计算并输出一个整数各位数字之和? - 网络|
  • web现在找工作容易吗? - 网络|
  • web现在找工作容易吗? - 网络| | web现在找工作容易吗? - 网络| ...