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