水仙花数
来源:互联网 发布:全景制作软件 编辑:程序博客网 时间:2024/05/16 11:40
打印水仙花数
- 描述
- 打印出所有得“水仙花数”,所谓“水仙花数”是指一个3位数,其各位数字的立方和等于该数本身,例如,152是水仙花数,因为153=1×1×1+5×5×5+3×3×3。
- 输入
- 无输入。
- 输出
- 输出所有水仙花数,每行输出一个水仙花数。
- #include<bits/stdc++.h>
ueing namespacs std;
int power(int a,int b)
{
int res=1;
while(b>0)
{
res=res*a;--b;
}
return res;
}
int main()
{
for(int num=100;num<1000;++num)
{
if(prower(num%10,3)+power(num/10%10),3)+power(num/100,3)==num cout<<num<<endl;
}
return 0;
} - 函数类型的题目,对着答案敲的,感觉还不是很懂。
阅读全文
1 0
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 水仙花数
- 生信脚本练习(10)找出fasta文件中最长的转录本
- 多条目展示
- docker镜像加速配置
- 矩阵A+B
- 2017年8月14日提高组T1 跳跃
- 水仙花数
- 排序算法之桶排序,冒泡排序,快速排序
- Linux 绑定双网卡
- taglib报The content of element type "taglib" must match "(tlib-version,jsp-version.....错误
- 删除链表中重复的结点
- hdu 4928 Series 2 (优化+模拟) 多次导数相关(数范围限制突破)
- 解决Idea 导入maven工程编译 Error running 'tms [clean]': Cannot run program "C:\Program Files\Java\jdk1.
- ScaLa 之 implict
- 电子书 VS 纸质书