当前位置:网站首页>OJ每日一练——水仙花数
OJ每日一练——水仙花数
2022-04-22 00:10:00 【KJ.JK】
问题描述:
打印出所有"水仙花数",所谓"水仙花数"是指一个三位数,其各位数字立方和等于该本身。 例如:153是一个水仙花数,因为153=13+53+3^3。 Output:

输入
无
输出
所有的水仙花数,从小的开始。 每行一个
Java代码:
public class Main{
public static void main(String[] args) {
int a,b,c,d;
for(d=100;d<1000;d++) {
a=d/100;
b=(d/10)%10;
c=d%10;
if(a*a*a+b*b*b+c*c*c==d) {
System.out.println(d);
}
}
}
}
C代码:
#include <stdio.h>
int main(){
int a,b,c,d;
for(d=100;d<1000;d++) {
a=d/100;
b=(d/10)%10;
c=d%10;
if(a*a*a+b*b*b+c*c*c==d) {
printf("%d\n",d);
}
}
}
作者:KJ.JK
本文仅用于交流学习,未经作者允许,禁止转载,更勿做其他用途,违者必究。
文章对你有所帮助的话,欢迎给个赞或者 star,你的支持是对作者最大的鼓励,不足之处可以在评论区多多指正,交流学习
版权声明
本文为[KJ.JK]所创,转载请带上原文链接,感谢
https://blog.csdn.net/m0_47384542/article/details/124333500
边栏推荐
- Kubernetes deployment: offline deployment of highly available kubernetes clusters using kubespreay (scheme 1)
- MES实施过程中为什么会出现需求变更?又该如何解决?
- Gartner发布新兴技术研究:深入洞悉元宇宙
- 稳压二极管限流电阻怎么选择
- 如何在任意网页引入复玥网节日破坏小飞机?
- 覆盖率系列学习之功能覆盖率COV
- Activity preview | on April 23, a number of wonderful openmldb sharing came, which lived up to the good time of the weekend!
- C# 利用委托事件进行窗体间的传值
- CODESYS读取csv文件的方法(非excel)
- Unity判断 (本地绝对目录下的)文件 是否存在
猜你喜欢

树和二叉树
![[leetcode daily question] goat Latin](/img/a0/d5d8690bd3438a87f6b6202b3eff3b.png)
[leetcode daily question] goat Latin

2022中国眼博会,北京青少年眼健康产业展会,护眼教育设备展

SqlServer——Excel连接数据库相关知识

Deep learning (15): instructions for kitti2bag

Architecture practice battalion - module III - operation

运动耳机选择哪种好、什么款式的耳机戴着舒服

Application and analysis of TVS Diode

1.2V Ni MH battery lamp solar lawn lamp boost drive IC silk screen printing aatlb package SOT23-6 and sop8 single chip microcomputer IC

Brush questions (I)
随机推荐
gdb调试应用程序记录
09. Raspberry pie ASP Net environment configuration
AI的新故事,藏在李彦宏的《智能交通》音频书里
浅谈摸鱼的快乐 —— 4月20日
架构实战训练 模块三
内存管理、
Kubernetes deployment: offline deployment of highly available kubernetes clusters using kubespreay (scheme 1)
细说MOS管知识-MOS管高端驱动与低端驱动解析和原理及区别
树和二叉树
Detailed MOS tube knowledge - MOS tube high-end drive and low-end drive analysis, principle and difference
架构实战营-模块三-作业
Redis starts the service and connects the client
Main parameters and structure of LED
开关电源中开关管与二极管EMI抑制方法分析
非常强大的时间日期插件 --- JeDate.js
Detailed explanation of redis benchmark performance test tool
TP4582B/TP4584B蓝牙充电座锂电池充放电芯片
续流二极管在开关电源的作用
Deep learning (15): instructions for kitti2bag
比较方便安全的期货开户怎么办理好?