文档详情

c语言题目含答案.doc

发布:2017-06-01约4.22千字共8页下载文档
文本预览下载声明
1、 程序改错题 30?分   2、 程序填空题 30?分   3、 程序编程题 40?分 模拟试卷1 以下是MODI.C源程序 #include conio.h #include stdio.h void main() { long s, t, sl=1; int d; //clrscr(); printf(\nPlease enter s:); scanf(%ld, s); t = 0; while ( s 0) { d = s%10; /************found************/ if (d%2=0) { t=d * sl + t; sl *= 10; } /************found************/ s = 10; } printf(The result is: %ld\n, t); } 以下为FILL.C源程序 #include math.h #include conio.h #include stdio.h long int fun(int x) {long int s=1; int i; for (i=1;i=x;i++) s*=i; /************found************/ ____(1)____; } void main() { long int m=12,n=2,s1,s2,s3; //clrscr(); s1=fun(m); s2=fun(n); s3=fun(m-n); /************found************/ printf(Cmn is : %ld,____(2)____ ); } 以下为prog.c的源程序 #include stdio.h #include math.h #include conio.h #include stdlib.h void main() { int m=6,n=45,t,i,temp; /***********begin***********/ /************end************/ printf(The Lowest Common Multiple of %d and %d is %d\n,m,n,t); NONO(m,n,t); } NONO( int m,int n,int s) { FILE *f; f=fopen(D:\\exam\\PROGOUT.DAT,w); fprintf(f,Minimal Common Multiple Of %d and %d is %d\n,m,n,s); fclose(f); } 模拟试卷2 以下为modi.c源程序 #include conio.h #include stdio.h sum ( int arr[ ],int n ) { int i,s; s = 0; for ( i=0; in; i++) if (arr[i] % 2 == 0) /************found************/ s = s + i; return (s); } void main() { int a[10]={10,4,2,7,3,12,5,34,5,9},i,s; /************found************/ s = sum( a ,2 ); printf(The result is: %d\n, s); } 以下为FILL.C源程序 #define M 5 void main( ) { int i,a[100],t; //clrscr(); for(i=0;iM;i++) /**************found************/ ___(1)___ /**************found************/ for(i=0;___(2)___;i++) a[M-i-1]=a[i]; for(i=0;iM;i++) printf(%5d,a[i]); prin
显示全部
相似文档