[电脑基础知识]C语言题库1.doc
《[电脑基础知识]C语言题库1.doc》由会员分享,可在线阅读,更多相关《[电脑基础知识]C语言题库1.doc(47页珍藏版)》请在三一办公上搜索。
1、基本操作题#includemain() int i,j,k,n=0; for(i=1;i=5;i+) for(j=1;j=10;j+) for(k=1;k=10;k+) if(i*10+j*5+k*1=100) n+;printf(i=%d j=%d k=%dn,i,j,k); printf(n=%d,n);#includemain() int a,b,*pa,*pb; pa=&a;pb=&b; scanf(%d,%d,&a,&b); *pa=a+b; *pb=a+b; printf(a=%d,b=%dn,a,b);#includemain() int x=1,y=0,a=0,b=0; swi
2、tch(x) case 1: switch(y) case 0:a+;break; case 1:b+;break; case 2:a+;b+;break; printf(a=%d,b=%dn,a,b);#includemain() char str80; int i,num; printf(输入一个字符串:); gets(str); num=0; for(i=0;stri!=0;i+) if(stri=a) num+; printf(字符串中有%d个字母an,num);#includemain() int a,b; for(a=1,b=1;a=20) break; if(b%3=1) b+=
3、3;continue; b-=5; printf(%dn,a);#includemain() char s120,s220; int i; printf(Input a string:n); gets(s2); for(i=0;s2i!=0;i+) s1i=s2i; s1i=0; printf(Output the new string:n); printf(%sn,s1);#include#includemain() float a,x,x1,e; printf( a= ); scanf(%f,&a); x=a; while(1) x1=2*x/3+a/(3*x*x); e=fabs(x1-
4、x); if(e0.00001)break; else x=x1; printf(a=%.0fn,a); printf(x=%.5fn,x1); printf(pow=%.5f,a,pow(a,1.0/3);#include main()int a,b,c,t;printf(输入a,b,c:);scanf(%d%d%d,&a,&b,&c);if(ab)t=a;a=b;b=t;if(ac)t=a;a=c;c=t;if(bc)t=b;b=c;c=t;printf(%d %d %dn,a,b,c);#includemain() int m,n,t; scanf(%d%d,&m,&n); t=mn?m
5、:n; if(t%2!=0) t+=1; printf(%dn,t);#includemain() int x=1,y=0,a=0,b=0; switch(x) case 1:switch(y) case 0:a+;break; case 1:b+;break; case 2:a+;b+;break; printf(a=%d,b=%dn,a,b);#includemain()int i,j,k,n;printf(请输入一个3位数:n);scanf(%d,&n);i=n/100;j=(n-i*100)/10;k=n%10;if(i*i*i+j*j*j+k*k*k=n) printf(该数是水仙数
6、);else printf(该数不是水仙数);#includemain()char s120,s220;int i;printf(Input a string:n);gets(s2);for(i=0;s2i!=0;i+)s1i=s2i;s1i=0;printf(Output the new string:n);printf(%sn,s1);程序改错题 #include #include #include main() int i,j,k; for(i=1;i=4;i+) /*found*/ for(j=1;j=4;j+) for(j=1;j=i;j+) printf(%3d *%3d =%3d
7、,i,j,i*j); /*found*/ printf(n); printf(n); #include #include main() int a20=9,3,0,4,1,2,5,6,8,10,7, n=11; int i, j, p, t; printf( nnBefore sorting %d numbers:n, n ); j = 0; for ( i = 1; i = n; i+, j+ ) printf( %4d, aj ); if ( !( i%10 ) ) printf( n ); printf(n); for ( j = 0; jn-1 ; j+ ) p = j; /*foun
8、d*/ for ( i=j+1; in-1 ; i+ ) for ( i=j+1; iai ) /*found*/ t=i; p=i; if ( p!=j ) t = aj; aj = ap; ap = t; printf( nAfter sorting %d numbers:n, n ); j = 0; for ( i = 1; i = n; i+, j+ ) printf( %4d, aj ); if ( !( i%10 ) ) printf( n ); printf(n); #include #include main() char s80,t80; int i, sl; printf(
9、nPlease enter string s:); scanf(%s, s); sl = strlen(s); /*found*/ for( i=0; i=sl; i+) ti = si; for (i=0; isl; i+) tsl+i = ssl-i-1; /*found*/ t2*sl = 0; printf(The result is: %sn, t); #include #include #include main() int m,j,n=0,k; for(m=200;m=300;m+) k=sqrt(m); for(j=2;jk) if(n%8=0) printf(n); /*fo
10、und*/ printf(%6d,j); printf(%6d,m); n+; #include main() int a10=1,4,2,7,3,12,5,34,5,9,i,max,pos; max = a0; pos = 0; for ( i=1; i ai) if(max ai) max = ai; /*found*/ i=pos; pos=i; printf(The max is: %d ,pos is: %dn, max , pos); #include int Prime(int n) int i; for(i=2;in) if(i=n) return 1; return 0;ma
11、in() int n; scanf(%d,&n); /*found*/ if(Prime(int n)=1) if(Prime(n)=1) printf(%d is a prime number.,n); else printf(%d is not a prime number.,n); #include main() int a10=10,4,2,7,3,12,5,34,5,9,i; float s = 0; for ( i=0; i10; i+) /*found*/ if (i % 2 = 0) if(ai%2=0) s = s + ai; /*found*/ print(The resu
12、lt is: %dn, s); printf(The result is: %.0fn, s); #include #include #include main() int i; int a,b,c; printf(isomorphic numbers are :n); for(i=1;i=100;i+) a=i*i%10; b=i*i%100/10; /*found*/ c=i*i%100; if(i10) /*found*/ if(i=a) printf(%6d,i); if(i=a) printf(%6d,i); else if(i=a+b*10) printf(%6d,i); prin
13、tf(n); #include #include #include main() int a5,x; int i; printf(请输入5个数:n); for(i=0;i5;i+) /*found*/ scanf(%d,ai); scanf(%d,&ai); printf(请输入x:n); scanf(%d,&x); for(i=0;i5;i+) if(ai=x)break; /*found*/ if(ai=x)printf(%d is in %d,x,i); else printf(not found!); #include #include #include main() int scor
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 电脑基础知识 电脑 基础知识 语言 题库
链接地址:https://www.31ppt.com/p-4558880.html