do…while练习

`int main()
{
//水仙花数是指一个3位数,它的每个位上的数字的三次幂之和等于它本身
//1.将所有三位数输出(100-999)
int num = 100;
do {
//2.在所有三位数中找到水仙花数
int a = 0;//个位
int b = 0;//十位
int c = 0;//百位

	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);`
原文地址:https://www.cnblogs.com/wjc970730/p/13821418.html