赞
踩
- #include <stdio.h>
- int main()
- {
- int n,m,t;
- int a,b,c;
- int count=0;
- while(~scanf("%d %d",&n,&m)){
- t=n;
- for(;n<=m;n++){ //水仙花数的判断
- c=n%10;
- b=n/10%10;
- a=n/100;
- if(n==a*a*a+b*b*b+c*c*c){
- count++;}
- }
-
-
- if(count==0)
- printf("no");
-
- if(count!=0)
-
- for(t;t<=m;t++){
- c=t%10;
- b=t/10%10;
- a=t/100;
- if(t==a*a*a+b*b*b+c*c*c){
- printf("%d ",t);
-
- }
- }printf("\n");
- count=0;//计数器归零,重新计数
-
-
-
- }
-
- return 0;
- }
多组区间输入判断水仙花数
赞
踩
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。