码迷,mamicode.com
首页 > 其他好文 > 详细

杭电2010-水仙花

时间:2015-03-08 22:53:40      阅读:202      评论:0      收藏:0      [点我收藏+]

标签:

#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
    int a,b,count,k1,k2,k3;
    while(cin>>a>>b)
    {
      for(count=0;a<=b;a++)
      {
         k1=a/100;
         k2=(a-k1*100)/10;
         k3=a-k1*100-k2*10;
         if(a==k1*k1*k1+k2*k2*k2+k3*k3*k3)
         {
             if(count!=0)
               cout<<" ";
             cout<<a;
             count++;
         }
         
      }
      if(count==0)
       cout<<"no"<<endl;
      else
      cout<<endl;
    }
    system("PAUSE");
    return EXIT_SUCCESS;
}

杭电2010-水仙花

标签:

原文地址:http://www.cnblogs.com/wft1990/p/4322380.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!