c++—寻找水仙花数
作者:互联网
学习循环结构小案例
#include<iostream> using namespace std; //水仙花数 //水仙花数是指一个3位数,它的每一位上的数字的三次幂之和等于它本身 int main() { int num = 100; int a = 0; int b = 0; int c = 0; do { a = num % 10;//个位 b = num / 10 % 10;//十位 c = num / 100;//百位 if(a*a*a+b*b*b+c*c*c==num) { cout << num << endl; } num++; } while (num < 1000); system("pause"); return 0; }
TRANSLATE with x English TRANSLATE with COPY THE URL BELOW Back EMBED THE SNIPPET BELOW IN YOUR SITE Enable collaborative features and customize widget: Bing Webmaster Portal Back
标签:10,int,寻找,c++,num,location,document,水仙花 来源: https://www.cnblogs.com/haipengwu/p/15631166.html