#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\n",count,j);
}
}
}

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

posted on 2016-05-08 20:20  薄樱  阅读(306)  评论(0编辑  收藏  举报