当前位置:网站首页>打出三位数的所有水仙花数「建议收藏」
打出三位数的所有水仙花数「建议收藏」
2022-07-01 20:21:00 【全栈程序员站长】
大家好,又见面了,我是你们的朋友全栈君。
/**
* 题目:打印出所有的 "水仙花数 ",所谓 "水仙花数 "是指一个三位数,
* 其各位数字立方和等于该数本身。例如:153是一个 "水仙花
* 数 ",因为153=1的三次方+5的三次方+3的三次方
*/
public class 水仙花数 {
public static void main(String[] args) {
for (int i = 100; i < 1000; i++) {
int first = i/100;
int secode= i/10%10;
int thrid = i%10;
if (first*first*first+secode*secode*secode+thrid*thrid*thrid == i) {
System.out.println(i+"是水仙花数");
}
}
}
}发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/147187.html原文链接:https://javaforall.cn
边栏推荐
- 升级版手机检测微信工具小程序源码-支持多种流量主模式
- Use Zadig to build a continuous delivery platform from 0 to 1
- 如何用OpenMesh创建一个四棱锥
- EMC-电路保护器件-防浪涌及冲击电流用
- Review notes of Zhang Haifan in introduction to software engineering (Sixth Edition)
- Practical project notes (I) -- creation of virtual machine
- leetcode刷题:栈与队列05(逆波兰表达式求值)
- cmake工程化相关
- 多个张量与多个卷积核做卷积运算的输出结果
- [multithreading] realize the singleton mode (hungry and lazy) realize the thread safe singleton mode (double validation lock)
猜你喜欢
随机推荐
Accelera Systems Initiative是一个独立的非营利组织
Target detection - Yolo series
Myslq ten kinds of locks, an article will take you to fully analyze
Détection des cibles - série Yolo
【opencv】train&test HOG+SVM
Richview trvdocparameters page parameter settings
2022年低压电工考试试题及答案
网上开户是安全的吗?新手可以开炒股账户吗。
利用QEventLoop实现同步等待槽函数返回
leetcode刷题:栈与队列03(有效的括号)
What if the win11 shortcut key switching input method doesn't respond? Shortcut key switching input method does not respond
Niuke programming question -- must brush the string of 101 (brush the question efficiently, draw inferences from one instance)
UVM教程
收藏:存储知识全面总结
关联线探究,如何连接流程图的两个节点
寫博客文檔
internship:逐渐迈向项目开发
Gaussdb (for MySQL):partial result cache, which accelerates the operator by caching intermediate results
多个张量与多个卷积核做卷积运算的输出结果
2022年高处安装、维护、拆除考题模拟考试平台操作









