题解 | #水仙花数#

水仙花数

https://www.nowcoder.com/practice/dc943274e8254a9eb074298fb2084703

#include <stdio.h>
#include "math.h"
int main() {
      int a,b,c,d,e,count;
    while (scanf("%d %d",&a,&b)!=EOF) {
        count=0;
        for (int i=a;i<=b;i++) {
             c=i%10;
             d=i/10%10;
             e=i/100;
           if (pow(c,3)+pow(d,3)+pow(e,3)==i){
               printf("%d ",i);
               count++;        
           }  
        }
             
              if(count==0){
                printf("no\n");
              }
    }
    return 0;
}

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务