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
Arabic Hebrew Polish
Bulgarian Hindi Portuguese
Catalan Hmong Daw Romanian
Chinese Simplified Hungarian Russian
Chinese Traditional Indonesian Slovak
Czech Italian Slovenian
Danish Japanese Spanish
Dutch Klingon Swedish
English Korean Thai
Estonian Latvian Turkish
Finnish Lithuanian Ukrainian
French Malay Urdu
German Maltese Vietnamese
Greek Norwegian Welsh
Haitian Creole Persian  
c++—寻找水仙花数 c++—寻找水仙花数 c++—寻找水仙花数 c++—寻找水仙花数   TRANSLATE with c++—寻找水仙花数 COPY THE URL BELOW c++—寻找水仙花数 c++—寻找水仙花数 Back EMBED THE SNIPPET BELOW IN YOUR SITE c++—寻找水仙花数 Enable collaborative features and customize widget: Bing Webmaster Portal Back
上一篇:Java程序员从笨鸟到菜鸟全部博客目录


下一篇:iOS开发系列--音频播放(音效和音乐)播放本地的