Java中的阿姆斯特朗编号。
以下是必需的程序。
public class Tester {
public static void main(String[] args) {
int c = 0, a, temp;
int m = 153;
int n = m;
temp = n;
while (n > 0) {
a = n % 10;
n = n / 10;
c = c + (a * a * a);
}
if (temp == c)
System.out.println(m + " is an armstrong number");
else
System.out.println(m + "is not an armstrong number");
}
}输出结果
153 is an armstrong number
热门推荐
2 敏字的祝福语简短
10 六一简短祝福语有哪些
11 生日哥哥祝福语简短独特
12 哥哥结婚的祝福语简短
13 新年送老师简短祝福语
14 新老师祝福语 简短独特
15 企业励志拜年祝福语简短
16 朋友领证祝福语长文简短
17 给司机老师祝福语简短
18 道教生日祝福语简短大全