代码拉取完成,页面将自动刷新
//水仙花数
public class ch3_2{
public static int scf(int n) {
int m=1;
for(int i=0; i<3; i++) {
m=m*n;
}
return m;
}
public static void main(String[] args){
int i,a,b,c;
int count = 0;
for(i=100; i<=999; i++) {
a = i/100;
b = i%100/10;
c = i%10;
if(scf(a)+scf(b)+scf(c) == i) {
count+=1;
System.out.println(i+"是水仙花数");
}
}
System.out.println("100~999一共有"+count+"个水仙花数");
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。