您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

用c语言求1到1000的同构数

2024/12/16 7:50:13发布16次查看
具体请看实例:
免费视频教程推荐:c语言视频教程
#include<stdio.h>#include<stdlib.h>#include<string.h>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<len;j++,ms--);return ms;}
相关文章教程分享:c语言教程
以上就是用c语言求1到1000的同构数的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product