c语言基础编程——while循环找出水仙花数

水仙花数是指一个N位正整数(N>=3),它的每个位上的数字的N次幂之和等于它本身。
如153=1^3+5^3+3^3。本题要求编写程序 计算所有N位水仙花数。
输入格式:
输入在一行中给出一个正整数N(3<=N<=7)
输出格式:
按递增顺序输出所有N为水仙花数,每个数字占一行。

注:while(i

#include 
int main()
{
	int n;
	scanf("%d",&n); 
	
	int first=1;
	int i=1;
	//这个while循环用于得出这N位数中第一个要开始遍历的数,100 or 1000 or ... 
	while(i0);
		
		if(sum==i){
			printf("%d\n",i);
		}
		i++;
	}
	return 0;
}

 

你可能感兴趣的:(c语言)