//C語(yǔ)言判斷Armstrong數(shù)(阿姆斯壯數(shù)),Armstrong 數(shù),就是n位數(shù)的各位數(shù)的n次方之和等于該數(shù),如:153=13+53+33,1634=14+64+34+4^4
include <stdio.h>
include <math.h>
int main()
{
int r, number, i, n = 0, j = 0;
printf("輸入一個(gè)正整數(shù):");
scanf("%d", &number);
r = number;
while (r != 0)
{
r /= 10;
j++;
}
r = number;
while (r != 0)
{
i = r % 10;
n += pow(i, j);
r /= 10;
}
if (n == number)
{
printf("%d是阿姆斯壯數(shù)。\n", number);
}
else
{
printf("%d不是阿姆斯壯數(shù)。\n", number);
}
return 0;
}