[Huawei Machine Test exercises]58. Finding the number of isomorphic numbers

Source: Internet
Author: User

Topic

Describe:

找出1至n之间同构数的个数。同构数是这样一组数:它出现在平方数的右边。例如:5是25右边的数,25是625右边的数,5和25都是同构数。

Detailed Description:

Interface description
Prototype:

intSearchSameConstructNum(int n);

Input parameters:

int n:查找1至n之间的全部同构数

return value:

int:1至n之间同构数的个数

Practice Stage:

Code

/* ---------------------------------------* Date: 2015-07-05* sjf0115* title: Find the number of isomorphic numbers * Source: Huawei Machine Test Exercises-------------------- ---------------------*/#include <iostream>#include "OJ.h"#include <vector>#include <cmath>#include <algorithm>using namespace STD;/* Function: Find the number of isomorphism between 1 and n input: int n: Find the total number of isomorphism between 1 to N returns: the number of isomorphism between Int:1 to n * /intSearchsameconstructnum (intN) {intsquare,tmp;intCount =0; for(inti =1; I <= n;++i) {square = i * i; TMP = i; while(TMP) {if(Square%Ten! = tmp%Ten){ Break; }//ifSquare/=Ten; TMP/=Ten; }//while        if(TMP = =0) {++count; }//if}//for    returnCount;}

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

[Huawei Machine Test exercises]58. Finding the number of isomorphic numbers

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.