C++打印水仙花数
#include <iostream>
#include <Windows.h> using namespace std; int main(void) {
int a, b, c; for (int i = ; i <= ; i++) {
a = i % ; // 用变量i除10取余得到个位数
b = (i / ) % ; // 先对变量i除10,再对结果除10取余得到十位数
c = i / ; // 用变量i除100得到百位数 // 判断i是否是水仙花数
if (a*a*a + b * b*b + c * c*c == i) {
cout << i << endl;
}
}
system("pause");
return ;
}

C++打印水仙花数的更多相关文章
- 打印水仙花数(narcissus number)
题目:打印出所有的"水仙花数(narcissus number)",所谓"水仙花数"是指一个三位数,其各位数字立方和等于该数本身.例如:153是一个" ...
- Java50道经典习题-程序3 打印水仙花数
题目:打印出所有的"水仙花数",所谓"水仙花数"是指一个三位数,其各位数字立方和等于该数本身.例如:153是一个"水仙花数",因为153=1 ...
- python打印水仙花数的个人总结
面试过程中,提到python,面试最多的就是让你现场写代码实现水仙花.冒泡.九九乘法表,这些面试方法旨在校验面试者的python基础和思维逻辑. 先从水仙花说起,水仙花是指一个n位正整数(n>= ...
- 【Java基础】for循环实现在控制台打印水仙花数
代码: /* * 需求:在控制台输出所有的”水仙花数” * * 分析: * 什么是水仙花数呢? * 所谓的水仙花数是指一个三位数,其各位数字的立方和等于该数本身. * 举例:153就是一个水仙花数. ...
- java 打印水仙花数
package cn.lijun.demo6; public class Test2 { public static void main(String[] args) { for(int i=100; ...
- Java打印水仙花数
public class Test2 { public static void main(String[] args) { //水仙花 数 指的是一个三位数(100-999) //三位数本身= 百位数 ...
- Java程序设计之打印100~999的水仙花数
package printDaffodilNumber; /* * 题目:打印出所有的"水仙花数",所谓"水仙花数"是指一个三位数,其各位数字立方和等于该数本身 ...
- 题目:打印出所有的 "水仙花数 ",所谓 "水仙花数 "是指一个三位数,其各位数字立方和等于该数本身。例如:153是一个 "水仙花 数 ",因为153=1的三次方+5的三次方+3的三次方。
题目:打印出所有的 "水仙花数 ",所谓 "水仙花数 "是指一个三位数,其各位数字立方和等于该数本身.例如:153是一个 "水仙花 数 ", ...
- C语言成绩测试 ,水仙花数,打印星图
#include <stdio.h>//输入输出头文件 #include<string.h> #include<stdlib.h> //局部被调用函数1 成绩检测 ...
随机推荐
- Spring boot Security 登陆安全配置
实现的效果 访问url时,如果未登录时跳转到Login界面,要求用户登陆,如果登陆过返回请求的数据. 效果图 访问数据时,未登录返回login界面 登陆操作 登陆成功进入登出界面 登陆成功后再次访问数 ...
- springcloud config自动刷新中文乱码问题
摘录一段网上盛传的,如下: 在使用 spring cloud config 时,如果在 properties 文件里面有中文的话,会出现乱码. 乱码的原因是:spring 默认使用org.spring ...
- currency
currency 美 ['kʌrənsi] 英 ['kʌrənsi] n.货币:通货:通用:流行 网络流通:货币型:币种
- SiamRPN: High Performance Visual Tracking with Siamese Region Proposal Network
High Performance Visual Tracking with Siamese Region Proposal Network 2018-11-26 18:32:02 Paper:http ...
- TP5单元测试
tp5版本: 5.0.24 单元测试版本:1.* 1. 安装单元测试扩展: composer require topthink/think-testing .* 2.安装完毕,运行 php think ...
- Faster, more memory efficient and more ordered dictionaries on PyPy
Faster, more memory efficient and more ordered dictionaries on PyPy https://morepypy.blogspot.com/20 ...
- ISO/IEC 9899:2011 条款6.8.4——选择语句
6.8.4 选择语句 语法 1.selection-statement: if ( expression ) statement if ( expression ...
- python-learning-第二季-数据处理numpy
https://www.bjsxt.com/down/8468.html numpy-科学计算基础库 例子: import numpy as np #创建数组 a = np.arange() prin ...
- 【转】asp获取【微信公众平台】Access Token的源代码下载
在做微信开发时候,经常要用到Access Token,但是官网提供的都是基于php写的,我用asp写了,有需要可以直接复制去用,模板消息,jdk上传图片,客服消息等全需要这个:'获取 access_t ...
- Windows下MariaDB数据库安装图文教程
MariaDB是基于MySQL的开源数据库,兼容MySQL,现有的MySQL数据库可以迁移到MariaDB中使用 说明: MariaDB是基于MySQL的开源数据库,兼容MySQL,现有的MySQ ...