求水仙花数

for循环书写水仙花数

#include<iostream>
using namespace std;
int main()
{
int num = 0;
int a=0, b=0, c=0;
for (num=0;num<1000;num++)
{
a = num / 100;
b = (num % 100) / 10;
c = num % 10; if (num == a * a * a + b * b * b + c * c * c)
{
cout << "该数为水仙花数:" << num << endl;
} }
system("pause");
return 0;
}

do while循环书写水仙花数

int main()
{
int num =100;
int a = 0, b = 0, c = 0;
do
{
a = num / 100;
b = (num % 100) / 10;
c = num % 10;
if (num == a * a * a + b * b * b + c * c * c)
{
cout << "该数为水仙花数:" << num << endl;
}
num++;
} while (num < 1000);
system("pause");
return 0;
}

敲桌子小游戏

for循环书写

#include<iostream>
using namespace std;
int main()
{
int num = 0;
for (num = 0; num < 100; num++)
{
if (num % 10 == 7 || num / 10 == 7 || num % 7 == 0)
{
cout << "桌子" << endl;
}
else
{
cout << num << endl;
}
}
system("pause");
return 0;
}

求水仙花数和敲桌子小游戏(C++版)的更多相关文章

  1. php 求水仙花数优化

    水仙花数是指一个n位数(n>=3),它每一个位上数字的n次幂之和等于它本身,n为它的位数.(比如:1^3+5^3+3^3 = 153) 水仙花数又称阿姆斯特朗数. 三位的水仙花数有4个:153, ...

  2. 二、求水仙花数,打印出100-999之间所有的"水仙花数"

    所谓"水仙花数"是指一个三位数,其各位数字立方和等于该数本身. 例如:153是一个"水仙花数",因为153=1的三次方+5的三次方+3的三次方 public c ...

  3. js中求水仙花数

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  4. python基础----求水仙花数

    水仙花数,即一个三位数,各个位上的数字的三次方相加,等于该数本身.如:153 = 1**3 + 5 ** 3 + 3 ** 3 def is_narc_num(n): # if n <100 o ...

  5. java 求水仙花数

    package com.yc.bean; public class ShuiXianHua { public static void main(String[] args) { /** * 题目:打印 ...

  6. Python小代码_9_求水仙花数

    for i in range(100, 1000): ge = i % 10 shi = i // 10 % 10 bai = i // 100 if ge ** 3 + shi ** 3 + bai ...

  7. 简单的Java逻辑小代码(打擂台,冒泡排序,水仙花数,回文数,递归)

    1.打擂台 简单的小代码,打擂台.纪念下过去,祝福下新人. public static void main(String[] args){ int[] ld = {1,4,2,10,8,9,5}; i ...

  8. C#学习笔记(29)——Linq的实现,Lambda求偶数和水仙花数

    说明(2017-11-22 18:15:48): 1. Lambda表达式里面用了匿名委托,感觉理解起来还是挺难的.求偶数的例子模拟了Linq查询里的一个where方法. 2. 蒋坤说求水仙花数那个例 ...

  9. java求1000以内的水仙花数

    水仙花数是指一个 n 位数 ( n>=3 ),它的每个位上的数字的 n 次幂之和等于它本身.(例如:1^3 + 5^3 + 3^3 = 153) 三位的水仙花数共有4个,分别为:153.370. ...

  10. PHP水仙花数的实现

    php水仙花数是什么? 水仙花数是指一个 n 位数 ( n≥3 ),它的每个位上的数字的 n 次幂之和等于它本身.(例如:1^3 + 5^3 + 3^3 = 153)三位的水仙花数共有4个:153,3 ...

随机推荐

  1. w3cschool-Apache Storm 教程

    https://www.w3cschool.cn/apache_storm/ Apache Storm教程Apache Storm简介Apache Storm核心概念Apache Storm集群架构A ...

  2. 虚拟化基础vSphere

  3. java内部类与单例模式

    java中不允许外部类使用 private,protected 修饰 所谓的外部类:就是在源码中直接声明的类 所谓的内部类: 就是类中声明的类,内部类可以使用 public, private, pro ...

  4. SQL Server统计信息更新会被阻塞或引起会话阻塞吗?

    在SQL Server数据库中,统计信息更新(UPDATE STATISTICS)会被其它会话阻塞吗?统计信息更新(UPDATE STATISTICS)会引起其它会话阻塞吗?在回答这两个问题前,我们必 ...

  5. Zabbix Server 5.0 安装及Zabbix5.2 一键部署脚本

    zabbix 5.0 安装部署 1.关闭防火墙和selinux,安装repository源 [1]关闭防火墙,SELINUX firewall-cmd --state #查看默认防火墙状态,关闭后显示 ...

  6. linux mint安装Idea

    一.前言 这一节我们介绍在Linux下如何安装与破解Intellij idea2017.现在有很多公司开发环境都是Linux,所以掌握在Linux环境下使用Idea办公也是咱们必须得掌握的技能. 记住 ...

  7. 深入掌握 SQL 深度应用:复杂查询的艺术与技巧

    title: 深入掌握 SQL 深度应用:复杂查询的艺术与技巧 date: 2025/2/10 updated: 2025/2/10 author: cmdragon excerpt: SQL(结构化 ...

  8. Luogu P9606 CERC2019 ABB 题解 [ 绿 ] [ KMP ] [ 字符串哈希 ]

    ABB:KMP 的做法非常巧妙. 哈希 思路 显然正着做一遍哈希,倒着做一遍哈希,然后枚举回文中心即可. 时间复杂度 \(O(n)\). 代码 #include <bits/stdc++.h&g ...

  9. C#/.NET/.NET Core技术前沿周刊 | 第 25 期(2025年2.1-2.9)

    前言 C#/.NET/.NET Core技术前沿周刊,你的每周技术指南针!记录.追踪C#/.NET/.NET Core领域.生态的每周最新.最实用.最有价值的技术文章.社区动态.优质项目和学习资源等. ...

  10. WPF中实现PropertyGrid的三种方式

    原文地址: https://www.cnblogs.com/zhuqil/archive/2010/09/02/Wpf-PropertyGrid-Demo.html 第一种方式:使用WindowsFo ...