C语言求同构数:求指定区间内的同构数#includestdio.h#includestdlib.h#includestring.hchar*right(char*ms,intlen);voidmain(){longa;intlen;charas[10];charms[20];printf(求[1,10000]中的同构数:\n);for(a=1;a=10000;a++){ultoalen=strlen(as);ultoa(a*a,ms,10);if(strcmp(as,right(ms,len))==0)(a,as,10);printf(%s其平方为%s\n,as,ms);}}char*right(char*ms,intlen){inti,j;for(i=0;i(signed)strlen(ms);ms++);for(j=0;jlen;j++,ms--);returnms;}c语言输出从m到n的孪生素数对#includestdio.h#includemath.hintprime(intn){inti;if(n2)return0;for(i=2;i=sqrt(n);i++)if(n%i==0)return0;return1;}voidmain(){inti,m,n;printf(m:);scanf(%d,&m);printf(n:);scanf(%d,&n);for(i=m;i=n-2;i++)if(prime(i)&&prime(i+2))printf(%d,%d\n,i,i+2);}c语言折半查找法#includestdio.h#includestring.hvoidmain(){intcz(inta,intx,inty,intc[]);intgh[10]={1,2,3,4,5,6,7,8,9,10};inth,w;scanf(%d,&h);w=cz(h,0,9,gh);if(w!=-1){printf(%d,gh[w]);}else{printf(没找到\n);}getch();}intcz(inta,intx,inty,intc[]){intm;if(xy)return-1;m=(x+y)/2;if(a==c[m]){returnm;}if(ac[m]){return(cz(a,x,m-1,c));}else{return(cz(a,m+1,y,c));}}c语言程序计算1~500之间的全部“同构数”之和。#includestdio.hvoidmain(){intn,he=0,a=0;doublepingfang;for(n=4;n10;n++){pingfang=n*n;if((pingfang-n)%10==0){printf(%5d,n);he+=n;a++;if(a%5==0)printf(\n);}}for(n=10;n100;n++){pingfang=n*n;if((pingfang-n)/100==0){printf(%5d,n);he+=n;a++;if(a%5==0)printf(\n);}}for(n=100;n=500;n++){pingfang=n*n;if((pingfang-n)/1000==0){printf(%5d,n);he+=n;a++;if(a%5==0)printf(\n);}}printf(1到500之间所有的同构数之和为:%5d\n,he);}用C语言验证歌德巴赫猜想(任何充分大的偶数都可以由两个素数之和表示)。#includestdio.hintf(intn){inti;for(i=2;in;i++)if(n%i==0)return0;return1;}intmain(){intnum,i,a,b,count=1;printf(请输入一个不小于6的偶数:\n);scanf(%d,&num);for(i=1;i=num/2;i++){a=i;b=num-i;if(f(a)==1&&f(b)==1){if(count%5==0)printf(\n);count++;printf(这个数可以为%d,%d组成.\n,a,b);}}return0;}找出一个数组中的最大值和最小值#includestdio.hvoidmain(){inta[8][8]={0};intl,r,i,j,min=65535,max=-65536;printf(inputlinenumber:);scanf(%d,&l);printf(inputcolumnnumber:);scanf(%d,&r);printf(inputthearray:\n);for(i=0;il;i++)for(j=0;jr;j++){scanf(%d,&a[i][j]);if(a[i][j]max)max=a[i][j];if(a[i][j]min)min=a[i][j];}for(i=0;il;i++)for(j=0;jr;j++)if(a[i][j]==max)printf(Max=%d,x=%d,y=%d\n,max,i+1,j+1);for(i=0;il;i++)for(j=0;jr;j++)if(a[i][j]==min)printf(Min=%d,x=%d,y=%d\n,min,i+1,j+1);getch();}