C++:找到三位数中的所有水仙花数

#include
using namespace std;
int main() {
	int num = 100;
	do {
		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<<" ";
		}
		num++;
	} while (num < 1000);
	system("pause");
	return 0;
}

你可能感兴趣的:(c++,算法,开发语言)