1、C语言求同构数:求指定区间内得同构数#include#include#includechar *right(char *ms,int len);void mainlong a;int len;char as10;char ms20;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 其平方为 %sn,as,ms);char *right(char *ms,int len)int i,j;fo
2、r(i=0;i(signed)strlen(ms);ms+);for(j=0;jlen;j+,ms);return ms;c语言 输出从m到n得孪生素数对#include #include int prime(int n) int i; if(n2) return 0; for(i=2;i=sqrt(n);i+) if(n%i=0) return 0; return 1; void main int i,m,n; printf(m:); scanf(%d,&m); printf(n:); scanf(%d,&n); for(i=m;i=n2;i+) if(prime(i) & prime(i+
3、2) printf(%d,%dn,i,i+2); c语言折半查找法#include #include void main int cz(int a,int x,int y,int c); int gh10 = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10; int h,w; scanf(%d,&h); w = cz(h, 0, 9, gh); if (w != 1) printf(%d, ghw); else printf(没找到n); getch;int cz(int a,int x,int y,int c) int m; if (x y) return 1; m = (x +
4、 y) / 2; if (a = cm) return m; if (a cm) return (cz(a, x, m1, c); else return (cz(a, m+1, y, c); c语言程序计算1500之间得全部“同构数”之与。#includevoid mainint n,he=0,a=0;double pingfang;for(n=4;n10;n+)pingfang=n*n;if(pingfangn)%10=0) printf(%5d,n);he+=n;a+;if(a%5=0)printf(n);for(n=10;n100;n+)pingfang=n*n;if(pingfang
5、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(pingfangn)/1000=0)printf(%5d,n);he+=n;a+;if(a%5=0)printf(n);printf(1到500之间所有得同构数之与为:%5dn,he);用C语言验证歌德巴赫猜想(任何充分大得偶数都可以由两个素数之与表示)。#include int f(int n) int i; for(i=2;in;i+) if(n%i=0) return 0; return 1; int main in
6、t num,i,a,b,count=1; printf(请输入一个不小于6得偶数:n); scanf(%d,&num); for(i=1;i=num/2;i+) a=i;b=numi; if(f(a)=1&f(b)=1) if(count%5=0) printf(n); count+; printf(这个数可以为%d,%d 组成、n,a,b); return 0; 找出一个数组中得最大值与最小值#include void main int a88=0;int l,r,i,j,min=65535,max=65536; printf(input line number:);scanf(%d,&l); printf(input column number:);scanf(%d,&r); printf(input the array:n);for(i=0;il;i+) for(j=0;jmax) max=aij;if(aijmin ) min=aij; for(i=0;il;i+) for(j=0;jr;j+) if(aij=max) printf(Max=%d,x=%d,y=%dn,max,i+1,j+1); for(i=0;il;i+) for(j=0;jr;j+) if(aij=min) printf(Min=%d,x=%d,y=%dn,min,i+1,j+1); getch;