Find the number of isomorphic numbers

Source: Internet
Author: User

    • Find out the number of isomorphic numbers between 1 and N. A homogeneous number is a group of numbers: it appears to the right of the square number. For example: 5 is the number to the right of 25, 25 is 625 to the right, and 5 and 25 are isomorphic numbers.

Detailed Description:

    • Interface description

Prototype:

    • int searchsameconstructnum (int n) ;

Input parameters:

int n: Finds all isomorphic numbers between 1 and N

return value:

int: Number of isomorphic numbers between 1 and N

Full code:

#include "OJ.h"/* Function: Find out the number of isomorphism between 1 to n input:    int N: Find the total number of isomorphism between 1 to N returns:    the number of isomorphism between Int:1 to N */int searchsameconstructnum ( int n) {/    * implements the function here */    long int m;    int k;    int cnt=0;    for (int i=1;i<=n;i++)    {    m=i*i;    k=i;    while (k)    {    if (k%10==m%10)    {    k=k/10;    M=M/10;    }    else break    ;    }    if (k==0)    cnt++;    }    return CNT;}



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

Find 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.