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
热门推荐
10 新婚祝福语简短句子
11 简短新婚铺被子祝福语
12 简短创意祝福语有什么
13 送菜的祝福语简短霸气
14 酒店客人祝福语简短
15 祝福语生日男朋友简短
16 对学姐的简短祝福语
17 简短祝福语蛋糕简笔画
18 男友红包祝福语简短精辟