Java打印水仙花数
public class Test2 {
public static void main(String[] args) {
//水仙花 数 指的是一个三位数(100-999)
//三位数本身= 百位数立方+十位数的立方+个位数的立方
//153 = 1*1*1+5*5*5+3*3*3
for(int i=100;i<1000;i++){
int bai=i/100%10; //
int shi = i/10%10;
int ge = i%10;
if(i==bai*bai*bai+shi*shi*shi+ge*ge*ge){
System.out.println(i);
}
}
}
}
Java打印水仙花数的更多相关文章
- java 打印水仙花数
package cn.lijun.demo6; public class Test2 { public static void main(String[] args) { for(int i=100; ...
- 【Java基础】for循环实现在控制台打印水仙花数
代码: /* * 需求:在控制台输出所有的”水仙花数” * * 分析: * 什么是水仙花数呢? * 所谓的水仙花数是指一个三位数,其各位数字的立方和等于该数本身. * 举例:153就是一个水仙花数. ...
- 打印水仙花数(narcissus number)
题目:打印出所有的"水仙花数(narcissus number)",所谓"水仙花数"是指一个三位数,其各位数字立方和等于该数本身.例如:153是一个" ...
- Java50道经典习题-程序3 打印水仙花数
题目:打印出所有的"水仙花数",所谓"水仙花数"是指一个三位数,其各位数字立方和等于该数本身.例如:153是一个"水仙花数",因为153=1 ...
- java 寻找水仙花数
题目:打印出所有的"水仙花数",所谓"水仙花数"是指一个三位数,其各位数字立方和等于该数本身.例如:153是一个"水仙花数",因为153=1 ...
- java 求水仙花数
package com.yc.bean; public class ShuiXianHua { public static void main(String[] args) { /** * 题目:打印 ...
- python打印水仙花数的个人总结
面试过程中,提到python,面试最多的就是让你现场写代码实现水仙花.冒泡.九九乘法表,这些面试方法旨在校验面试者的python基础和思维逻辑. 先从水仙花说起,水仙花是指一个n位正整数(n>= ...
- Java判断水仙花数
水仙花数 水仙花数(Narcissistic number)也被称为超完全数字不变数(pluperfect digital invariant, PPDI).自恋数.自幂数.阿姆斯壮数或阿姆斯特朗数( ...
- C++打印水仙花数
#include <iostream> #include <Windows.h> using namespace std; int main(void) { int a, b, ...
随机推荐
- Linux下使用bind,epoll对网络编程封装
body, table{font-family: 微软雅黑; font-size: 13.5pt} table{border-collapse: collapse; border: solid gra ...
- 第三篇 功能实现(3) (Android学习笔记)
第三篇 功能实现(3) ●发一个广播和启动一个隐式的Intent非常像,那么它们之间有什么区别呢? Implicit Intents (sent via startActivity( )) and B ...
- > Raiders 项目配置
VS2010 新建一个工程,把 源码目录\Source\T3DIICHAP01中的*.h 和*.cpp文件都拷到新工程中并添加 双击 源码目录\DirectX \ dx9sdkcp.exe会自动解 ...
- HashMap中hashCode()和equals()重要性
Java中HashMap根据hashCode()和equals()方法来获取键值对的索引,同时也通过这两个方法由key值获取value值.如果没有这两个方法,那么当有两个相同的 hash值时,可能会被 ...
- 1.6socket服务器传送文件--gui窗口
socket服务器代码 import sys,os,time,_thread from socket import * class Server(object): def __init__(self) ...
- matlab中hold on 和hold off功能的区别
hold off 使但当前轴及图形不具备被刷新的性质 hold on和hold off是相对使用的 前者为,你在当前轴(坐标系)中画了一幅图,再画另一幅是,原来的图还在,与新图共存,都看得到: 后者表 ...
- 将python环境打包成.txt文件
1 导出Python环境安装包[root@bogon ~]# pip freeze > packages.txt这将会创建一个 packages.txt文件,其中包含了当前环境中所有包及各自的版 ...
- 设置idea文件类型
- HDU 6143 17多校8 Killer Names(组合数学)
题目传送:Killer Names Problem Description > Galen Marek, codenamed Starkiller, was a male Human appre ...
- JAVA (StringBuffer/StringBuilder)常用API
public class Copy3 { public static void main(String[] args) { //构造实例化 StringBuffer strbu = new Strin ...