zoukankan      html  css  js  c++  java
  • HDU-2010

    求M和N之间的水仙花数

     1 #include<stdio.h>
     2 #include<stdlib.h>
     3 #include<math.h>
     4 #include<string.h>
     5 int main()
     6 {
     7     int m,n;
     8     int i;
     9     int s;
    10     int t;
    11     int count;
    12     int nu[1000];
    13     while(scanf("%d",&m)!=EOF)
    14     {
    15         scanf("%d",&n);
    16         count=0;
    17         for (i=m;i<=n;i++)
    18         {
    19             s=0;
    20             t=i;
    21             while (t!=0)
    22             {
    23                 s+=pow(t%10,3);
    24                 t/=10;
    25             }
    26             if (i==s) 
    27             {
    28                 count++;
    29                 nu[count]=i;
    30             }
    31         }
    32         i=1;
    33         if (count>=1)
    34         {
    35             for (i=1;i<count;i++)
    36                 printf("%d ",nu[i]);
    37             printf("%d
    ",nu[i]);
    38         }
    39         else printf("no
    ");
    40     }
    41     return 0;
    42 }
  • 相关阅读:
    TCP的初始cwnd和ssthresh
    C/C++ main
    PHP Function
    run bin
    PHP
    LAMP
    PHP MATH
    PHP array sort
    inline
    gcc g++
  • 原文地址:https://www.cnblogs.com/leiyuxiang/p/3489727.html
Copyright © 2011-2022 走看看