C语言求出三位数中的水仙花数

参考资料:https://blog.csdn.net/zhengxinyu666/article/details/79646252

#include
#include
int main() {
	int a = 0;
	int b = 0;
	int c = 0;
	int sum ;
	for (sum = 0; sum < 1000; sum++) {
		if (sum % 100 > 1)
		{
			 a = sum / 100;
			 b = sum %100/10;
			 c = sum % 10;
		}
		if (sum == a*a*a + b*b*b + c*c*c) {
			printf("%d\n", sum);
			system("pause");
		}
	}
	
	return 0;
}

你可能感兴趣的:(C语言求出三位数中的水仙花数)