Use C language to find isomorphic numbers from 1 to 1000

王林
Release: 2020-02-05 10:32:58
Original
10894 people have browsed it

Use C language to find isomorphic numbers from 1 to 1000

Please see examples for details:

Free video tutorial recommendation:c language video tutorial

#include #include #include char *right(char *ms,int len); /*截取一个字符串尾部长为len个字符的子串*/ void main() { long a; int len; char as[10]; char ms[20]; printf("求[1,10000]中的同构数:\n"); for(a=1;a<=10000;a++) { ultoa(a,as,10); /*数a转换为字符串,存入as*/ len=strlen(as); ultoa(a*a,ms,10); if(strcmp(as,right(ms,len))==0) /*比较字符串as与ms长为len的子串是否相等*/ printf("%s 其平方为 %s\n",as,ms); /*相等就是同构数,输出结果*/ } system("pause"); } char *right(char *ms,int len) /*截取字符串尾部长为len子串的函数*/ { int i,j; for(i=0;i<(signed)strlen(ms);ms++); for(j=0;j
        
Copy after login

Related article tutorial sharing:c language tutorial

The above is the detailed content of Use C language to find isomorphic numbers from 1 to 1000. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!