c++程序—水仙花数
#include<iostream> using namespace std; #include<string> #include<ctime> int main() { //找出100~999中的水仙花数 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 << endl; } num++; } while (num < 1000); system("pause"); return 0; }