zoukankan      html  css  js  c++  java
  • C++语言 同构数 求1000以内的同构数

    同构数

    同构数是会出现在它的平方的右边的数。如5×5=25,6×6=36。

    例子:求1000以内的同构数

    #include <iostream>
    #include <cmath> //数学函数
    #define N 1000 //定义常量
    
    using namespace std; //引用名字空间
    
    //求1000以内的同构数 转自http://www.pythonschool.com/蟒蛇学校
    int main(int argc, char* argv[])
    {
        long result;
        cout << "<------------1~1000之间的同构数----------->"<<endl;
        for( int i=N; i>=1; i-- )
        {
            result = pow(i,2);
            if( i<10 && i == result%10 ) //处理10以下的数
                cout << i << "    同构数   " << result << endl;
            else if( i>=10 && i == result%100 ) //处理100以下的数
                cout << i << "   同构数   " << result << endl;
            else if( i>=100 && i == result%1000 ) //处理1000以下的数
                cout << i << "  同构数   " << result << endl;
            else
                continue;
        }
        cout<<"<--------------------------------------->"<<endl;
        return 0;
    }
    学习笔记转摘于: 丝酷网 http://www.pythonschool.com/
  • 相关阅读:
    Life Forms POJ
    Musical Theme POJ
    Long Long Message POJ
    ci框架多语言切换
    vi模式
    并发量
    运维技术规划
    Linux装mysqli.so
    任何一门语言思考的
    python例子
  • 原文地址:https://www.cnblogs.com/pythonschool/p/2920360.html
Copyright © 2011-2022 走看看