水仙花数
来源:互联网 发布:测试丢包软件 编辑:程序博客网 时间:2024/04/25 02:36
#include<iostream>
using std::cout;
using std::endl;
long function(long s);//·µ»ØsµÄË®ÏÉ»¨ºÍ
int main()
{
long i;
const long n=82693916578;
for(i=0;i<=n;i++)
{
if(i==function(i))
cout<<i<<endl;
}
return 0;
}
long function(long s)
{
long sum=0;
int digit=0;
long temp=0;
long temps=s;
//»ñÈ¡sµÄλÊý,±£´æÔÚdigitÖÐ
while(temps)
{
digit++;
temps/=10;
}
//È¡µÃ¸÷λÊý×ÖµÄdigit´Î·½Ö®ºÍ
//ÒÀ´Î´Ó¸öλÊýÇóÆð,±£´æÔÚsumÖУ¬Ã¿´ÎÖ´ÐÐÍâÑ»·ºóÉáÆúsµÄ¸öλÊý×Ö£¬¼´½«s³ýÒÔ10
for(int t=0;t<digit;t++)
{
temp = s%10;//È¡µÃsµÄ¸öλÊý
temps=1;
//ÇóµÃtempµÄdigit´Î·½£¬±£´æÔÚtempsÖÐ
for(int k=0;k<digit;k++)
temps *=temp;
sum+=temps;
s/=10;//ÉáÆúsµÄ¸öλÊý
}
return sum;
}
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 递归删除某个文件夹下面的所有文件和文件夹
- Oracle Data Guard Linux 平台 Physical Standby 搭建实例
- 考试
- QT4应用程序挂载到arm板(利用nfs共享)
- IrrLicht 編譯與安裝
- 水仙花数
- 自己动手 制作makefile
- (转贴) gcc的扩展语法
- set_base 和 set_limitC语言实现版
- 如何保养汽车真皮座椅座套
- asp.net中"错误:回发或回调参数无效"
- 首次开通
- 详解Oracle用户解锁命令的两则实现方法
- 你最后悔什么