《C语言图形+数组答案.doc》由会员分享,可在线阅读,更多相关《C语言图形+数组答案.doc(6页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、#include void main() int i,j,k;for(i=0;i=4;i+) for(j=0;j=10+i;j+)printf( );for(k=1;k=9-2*i;k+)printf(%2c,D-i);printf(n);数组图形题答案:1.#include stdio.hmain() int i,j,k;for(i=0;i4;i+) for(j=0;j=10+i;j+) printf( ); for(k=1;k=7-2*i;k+) printf(%c,D-i); printf(n); 2.#include stdio.hmain() int i,j,k;for(i=0;i4
2、;i+) for(j=0;j=10+i;j+) printf( ); for(k=1;k=7-2*i;k+) printf(%d,4-i); printf(n); 3.#include stdio.hmain() int i,j,k;for(i=0;i4;i+) for(j=0;j=10;j+) printf( ); for(k=1;k=7-2*i;k+) printf(%c,m+k-1); printf(n); 4.#include stdio.hmain() int i,j,k;for(i=0;i4;i+) for(j=0;j=16-2*i;j+) printf( ); for(k=1;k
3、=2*i+1;k+) printf(%2d,i+1); printf(n); 5.#include stdio.hmain() int i,j,k;for(i=0;i4;i+) for(j=0;j=16-2*i;j+) printf( ); for(k=1;k=2*i+1;k+) printf(%2c,A+k-1); printf(n); 6.#include stdio.hmain() int i,j,k;for(i=0;i4;i+) for(j=0;j=16-2*i;j+) printf( ); for(k=1;k=2*i+1;k+) printf(%2d,k); printf(n); 7
4、.#include stdio.hmain() int i,j,k;for(i=0;i4;i+) for(j=0;j=10+2*i;j+) printf( ); for(k=1;k=7-2*i;k+) printf(%2c,a+k-1); printf(n); 8.#include stdio.hmain() int i,j,k;for(i=0;i4;i+) for(j=0;j=10+2*i;j+) printf( ); for(k=1;k=7-2*i;k+) printf(%2d,k); printf(n); 9.#include stdio.hmain() int i,j,k;for(i=
5、0;i4;i+) for(j=0;j=10;j+) printf( ); for(k=1;k=5-i;k+) printf(%2c,a+k-1); printf(n); 10.#include stdio.hmain() int i,j,k;for(i=0;i3;i+) for(j=0;j=10;j+) printf( ); for(k=1;k=4;k+) printf(%4d,4*i+k); printf(n); 11.#include stdio.hmain() int i,j,k;for(i=0;i3;i+) for(j=0;j=10;j+) printf( ); for(k=1;k=4
6、;k+) printf(%-4d,4*i+k); printf(n); 12.#include stdio.hmain() int i,j,k;for(i=0;i5;i+) for(j=0;j=10-i;j+) printf( ); for(k=1;k=0;i-) for(j=0;j11-i;j+) printf( ); for(k=1;k=2*i+1;k+) printf(*);printf(n); 13.#include stdio.hmain() int i,j,k;for(i=0;i5;i+) for(j=0;j=10+i;j+) printf( ); for(k=1;k=10;k+)
7、 printf(*); printf(n); 14.#include stdio.h#include math.hvoid main()double a1010=0,s=0;int i,j;for(i=0;i10;i+)for(j=0;j10;j+)if(i=j) aij=i;for(i=0;i10;i+)for(j=0;j10;j+)s=s+pow(aij,1.0/3); printf(n%lf,s);15.#include stdio.h#include math.hvoid main()double a66,s=1;int i,j,k=50;for(i=0;i6;i+) for(j=0;
8、j6;j+) aij=k;k+; for(i=0;i6;i+) for(j=0;j6;j+) if(i=j) s=s*pow(aij,1.0/3); printf(n%lf,s); (99.)16.#include stdio.h#include math.hvoid main()double a66,s=1;int i,j,k=21;for(i=0;i6;i+) for(j=0;j6;j+) aij=k;k+; for(i=0;i6;i+) for(j=0;j=j) s=s*pow(aij,1.0/3); printf(n%lf,s);17.#include stdio.hvoid main
9、()int a10=1,2,3,4,5,6,7,8,9,10,i,j,t; for(i=1;i=4;i+) t=a0; for(j=1;j=9;j+) aj-1=aj; a9=t; for(j=0;j=9;j+) printf(%2d,aj);18.#include stdio.h#include string.hvoid main()int a26=0,i=0;char b100; printf(imput a string:n); scanf(%s,b); while(bi!=0) if(a=bi&bi=z) abi-a+; i+; for(i=0;i=25;i+) printf(%4d,
10、ai); 20.#include stdio.h#include string.h#include stdlib.hvoid main()int a55,i,j;long s1=0,s2=0;printf(n);for(i=0;i5;i+) for(j=0;j5;j+) aij=rand();for(i=0;i5;i+) for(j=0;j5;j+) printf(%6d,aij); printf(n); for(i=0;i5;i+) for(j=0;j5;j+) if(i=j) s1+=aij; if(i+j=4) s2+=aij; printf(%6ld,%6ld,s1,s2); 21.#
11、include stdio.h#include stdlib.hvoid main()int a1010,i,j,k=0;double b10=0;printf(n);for(i=0;i10;i+) for(j=0;j10;j+) aij=rand();for(i=0;i10;i+) for(j=0;j10;j+) printf(%6d,aij); printf(n); for(i=0;i10;i+) for(j=0;j10;j+) bi+=ajk; k+; for(i=0;i10;i+) printf(%lf,bi/10); 22.#include stdio.h#include stdli
12、b.hvoid main()int a66,i,j,h=0,max;double s=1.0;printf(n);for(i=0;i6;i+) for(j=0;j6;j+) aij=rand();for(i=0;i6;i+) for(j=0;j6;j+) printf(%7d,aij); printf(n); max=a00; for(i=0;i6;i+) for(j=0;jmax) max=aij;h=i; for(i=0;i6;i+) s=s*ahi; printf(%lf,s); 23.#include stdio.h#include stdlib.hvoid main()int a66
13、,i,j,k=0;int b6;printf(n);for(i=0;i6;i+) for(j=0;j6;j+) aij=rand();for(i=0;i6;i+) for(j=0;j6;j+) printf(%7d,aij); printf(n); for(i=0;i6;i+) bi=aik; for(j=0;jbi) bi=aij; k+; for(i=0;i6;i+) printf(%7d,bi); 24.#include stdio.h#include math.hvoid main()int a8=87,97,96,45,23,65,78,50,b8=21,32,54,36,47,37
14、,38,55;int c8,i;double s=0;for(i=0;i8;i+) ci=ai*bi; s+=sqrt(1.0*ci); printf(%lf,s);25.#include stdio.h#include math.hvoid main()int a8=1,2,3,4,5,6,7,8,b8,i,t; for(i=0;i4;i+) t=ai;ai=a7-i;a7-i=t; printf(n); for(i=0;i8;i+) printf(%3d,ai);26.#include stdio.hvoid main()int a8=12,34,64,37,89,88,97,99,n,i
15、,t;printf(imput n:);scanf(%d,&n);for(i=0;i8;i+)if(ai=n) t=i;break;for(i=t;i7;i+)ai=ai+1;for(i=0;i7;i+)printf(%6d,ai);函数题答案:2#include stdio.hint ss(int n) int i,s=0; for(i=1;in-1;i+) if(n%i=0) s=s+i; return s; main() int n=1200,s; s=ss(n); if(s=n) printf(yes); else printf(no);3.#include stdio.hlong s
16、s(int n,int m) long i,s=0; for(i=n;i=m;i+) if(i%2=1) s=s+i; return s; main() int n=200,m=1000; printf(n%ld,ss(n,m);5#include stdio.hlong ss(int n,int m) int i;long s=0; for(i=n;i=m;i+) if(i%2=0) s=s+i; return s; main() int n=200,m=1000; printf(n%ld,ss(n,m);6#include stdio.hdouble ss(int n,int m) int
17、 i;double s=0; for(i=n;i=m;i+) if(i%2=0) s=s+1.0/i; return s; main() int n=200,m=1000; printf(n%lf,ss(n,m);7#include stdio.hint ss(int n) int flag=0; int gw,sw,bw,qw; gw=n%10; sw=(n%100)/10; bw=(n%1000)/100; qw=n/1000; if(gw+sw)=(bw+qw) flag=1; return flag; main() int i,s=0; for(i=1000;i=9999;i+) if
18、(ss(i) s+; printf(n%d,s);8#include stdio.hint ss(long n) int flag=0; int gw,sw,ww,qw; gw=n%10; sw=(n%100)/10; ww=n/10000; qw=(n%10000)/1000; if(gw+sw)=(ww+qw) flag=1; return flag; main() long i,s=0; for(i=10000;i=99999;i+) if(ss(i) s+; printf(n%ld,s);9#include stdio.hint ss(long n) int flag=0; int g
19、w,sw,ww,qw; gw=n%10; sw=(n%100)/10; ww=n/10000; qw=(n%10000)/1000; if(gw=ww&sw=qw) flag=1; return flag; main() long i,s=0; for(i=10000;i=99999;i+) if(ss(i) s+; printf(n%ld,s);10 int sh(int a,int n) int i,t; for(i=0;i=n/2;i+) t=ai; ai=an-i-1; an-i-i=t; return(a); #include stdlib.h #includetime.h main
20、() int a8,i; for(i=0;i8;i+) ai=rand(); for(i=0;i8;i+) printf(%8d,ai); printf(n); ds(a,8); for(i=0;i8;i+) printf(%8d,ai); 11 int ss(int n) int i,flag=1; for(i=2;in;i+) if(n%i=0) flag=0;break; return(flag); #include stdio.h main() int i,count=0; for(i=100;i=999;i+) if(ss(i) count+; printf(ncount=%d,co
21、unt); 12 int ss(int n) int i,flag=0; int gw,sw,bw,qw,zh; gw=n%10; sw=(n%100)/10; bw=(n%1000)/100; qw=n/1000; zh=gw+sw+bw+qw; if(zh%3=0&zh%4=0) flag=1; return(flag); #include stdio.h main() int i,count=0; for(i=1000;i=9999;i+) if(ss(i) count+; printf(ncount=%d,count); 13 #include math.h double sz(int
22、 a55) int i,j; double s=0; for(i=0;i5;i+) for(j=0;j5;j+) if(i+j=4) s=s+sqrt(1.0*aij); return s; #include stdio.h main() int a55=23,45,56,73,34,34,74,85,54,764,56,98,56,89,67,98,54,83,12,59,98,87,74,48,62; double s; s=sz(a); printf(n%lf,s);14 #include math.h double sz(int a55) int i,j; double s=0; fo
23、r(i=0;i5;i+) for(j=0;j=4) s=s+sqrt(1.0*aij); return s; #include stdio.h main() int a55=23,45,56,73,34,34,74,85,54,764,56,98,56,89,67,98,54,83,12,59,98,87,74,48,62; double s; s=sz(a); printf(n%lf,s);15 #include math.h double sz(int a55) int i,j; double s=0; for(i=0;i5;i+) for(j=0;j5;j+) if(aij%2=0) s
24、=s+sqrt(1.0*aij); return s; #include stdio.h main() int a55=23,45,56,73,34,34,74,85,54,764,56,98,56,89,67,98,54,83,12,59,98,87,74,48,62; double s; s=sz(a); printf(n%lf,s);16 #include math.h double sz(int a55) int i,j; double s=0; for(i=0;i5;i+) for(j=0;j5;j+) if(aij%2=1) s=s+sqrt(1.0*aij); return s;
25、 #include stdio.h main() int a55=23,45,56,73,34,34,74,85,54,764,56,98,56,89,67,98,54,83,12,59,98,87,74,48,62; double s; s=sz(a); printf(n%lf,s);17 #include stdio.h int sxh(int n) int gw,sw,bw,flag=0; gw=n%10; sw=(n%100)/10; bw=n/100; if(gw*gw*gw+sw*sw*sw+bw*bw*bw)=n) flag=1; return flag; main() int
26、i,count=0; for(i=100;i0) ai=n%7; n=n/7; i+; i-; for(j=0;j(i+1)/2;j+) t=aj;aj=ai-j;ai-j=t; return(i+1); main() long i=,k,a50; k=ss(,a); printf(n); for(i=0;i0) ai=n%7; n=n/7; i+; i-; for(j=0;j(i+1)/2;j+) t=aj;aj=ai-j;ai-j=t; return(i+1); main() long i=,k,a50; k=ss(,a); printf(n); for(i=0;ik;i+)printf(
27、%ld,ai);20#include stdio.hint ss(double a,int n) int gs=0,i; double aver=0; for(i=0;in;i+) aver=aver+ai; aver=aver/n; for(i=0;in;i+) if(aiaver) gs+; return gs; main() double a9=1253,5647,6849,5962,4567,2361,1247,5241,6124;int count; count=ss(a,9); printf(n%d,count); 22 #include stdio.h int ss(int n) int gw,sw,bw,qw,ww,a,b,flag=0; gw=n%10; sw=(n%100)/10; bw=(n%1000)/100; qw=(n%10000)/1000; ww=n/10000; a=gw+10*sw; b=qw+ww*10; if(a%7=0&bw%7=0&b%7=0) flag=1; return flag; main() int i; int count=0; for(i=10000;i=30000;i+) if(ss(i) count+; printf(ncount=%d,count);
限制150内