Armstrong数

#include<stdio.h>
bool IsArmstrong(int a)
{
int x,y,z,sum;
x=a/100;
y=(a-100*x)/10;
z=(a-100*x-10*y);
sum=x*x*x+y*y*y+z*z*z;
if(sum==a)
return true;
else
return false;
}
void main()
{
int count=0;
for(int j=100;j<1000;j++)
{
if(IsArmstrong(j))
{ count=count+1;
printf("第%d个Armstrong数为%d ",count,j);
}
}
}

这个没什么好说的,代码和思想都很简单

原文地址:https://www.cnblogs.com/yunerlalala/p/5471414.html