1、第二部分:改错题第一套卷:cmody011.c#include #include #include #include void main() char str1100, t200; int i, j; /*/ i = 0; /*/ j=0 clrscr(); strcpy(str1, 4AZ18c?Ge9a0z!); for (i = 0; istrlen(str1); i+) /*/ if (str1i %2= 0) & (i%2!=0) /*/ if (str1i %2= 0) & (i%2=0) tj = str1i; j+; tj = 0; printf(n Original stri
2、ng: %sn, str1); printf(n Result string: %sn, t);*cmody012.c#include #include #include #include #define M 50double fun(int n) double y = 0.0; int i,j; j=0; for(i=1;i+) /*/ if(i10)&(i%3=0)(根据题义) /*/ y+=1/i; /*/ y+=1.0/i; j+; if(j=n) break; return y;void main() clrscr(); printf(fun(8) = %8.3lfn, fun(8)
3、;*第二套卷*cmody021.c#include void main()/*/ int i; j; /*/ int i, j;(概念错误) for (i=1;i=5;i+) for (j=1;j=10-2*i;j+) printf( );/*/ for (j=1;j=5;j+) /*/ for (j=1;j=2*i-1;j+) *号旳位置 printf(* ); printf(n); cmody022.c#include #include /*/int fun();/*/ int fun()(概念错误) int hen,cock,chicken,n=0; clrscr(); for(cock
4、=0;cock=50;cock+=1) for(hen=0;henhen:%d,cock:%d,chicken:%dn,n,hen,cock,chicken); if(n=20) getch(); return n;void main() int num; num=fun(); printf(n There are %d solutions.n,num); getch(); 第三套卷*cmody031.c#include #include void main() int m,n,result,flag=0; /*/ char ch, /*/ char ch;(概念错误) clrscr(); p
5、rintf(Input an expression: ); scanf(%d%c%d,&m,&ch,&n); /*/ switch ch /*/ switch (ch) case +: result=m+n; break; case -: result=m-n; break; case *: result=m*n; break; case %: result=m%n; break; case /: result=m/n; break; default: printf(Error!n); flag=1; if (!flag) printf(%d %c %d = %dn,m,ch,n,result
6、); getch();*cmody032.c#include #include void main() int num; printf(n); num=fun(); printf(nThe total of prime is %d,num); getch(); int fun() int m,i,k,n=0; for(m=201; m=300;m+=2) k=sqrt(m+1); for(i=2;i=k) printf(%-4d,m); n+; if(n%10=0) printf(n); return n;模拟卷*evsum.c#include void main()/*/ int sum=1
7、,i; /*/ int sum=0,i for(i=100; i1; i-)/*/ if(i%2=0) sum+=i; /*/ if(i%2=0) sum+=i; printf(%dn,sum);*dafsum.c#include void main() int i,a,b,c;/*/ for(i=100;i=999;i+) /*/ for(i=100;i=999;i+) a=i/100; /*/ b=i%10/10; /*/ b=i/10%10; c=i%10; /*/ if i=a*a*a+b*b*b+c*c*c /*/ if(i=a*a*a+b*b*b+c*c*c) printf(%5d
8、,i); *第三部分:填空题(每题10分)第一套卷*ccon011.c#include #include void main() int x; /*/ float f ; /*/ printf(Input an integer: ); scanf(%d,&x); f = /*/ (fabs(x)-2)/(x*x+1) /*/ ; printf(F(x)=%fn,f);*ccon012.c#include void main() double pi=0; long i, sign=1; for(i=1;i=10001;i+=2) pi+=1.0*sign/i; sign=/*/ -sgn; /*
9、/; 题义中是正负交替旳 pi*=/*/ 4 /*/; 前面一种系数 printf(%fn,pi);*ccon013.c#include #include int max,min;void find_max_min(int *p,int n) int *q; max=min=*p; for(q=p; q/*/ p+num /*/; q+) 指针从p开始,向下移动,直到结束p+num if(/*/ max*q) min=*q;void main() int i,num10; printf(Input 10 numbers: ); for(i=0;i10;i+) scanf(%d,&numi);
10、find_max_min(/*/ num /*/,10); 将主函数中旳数组值指针传递给子函数 printf(max=%d,num=%dn,max,min); 第二套卷*ccon021.c#include void main() int a,b,k; int plu = /*/ 403 /*/;根据题义 for(a=1; a10; a+) for(b=1; b10; b+) k = (a*10+b) * /*/(b*10+a ) /*/ ; 根据题义体现式 if(k=plu) printf(A = %d, B = %dn,a,b); *ccon022.c#include void main()
11、 int n,a,b; /*/ a=0,b=0 /*/ scanf(%d,&n); while(/*/ n /*/) if(n0) a+; else /*/ b+; /*/ scanf(%d,&n); printf(Positive integer: %d, negative integer: %dn,a,b);*ccon023.c#include #include int prime(int n) int k,flag=1; for(k=2; k=n/2+1; k+) if (n%k=0) flag=/*/ 0 /*/ ; break; return flag;void main() int
12、 num, a; clrscr(); do printf(Please input an even number:); scanf(%d, &num); while(num=6|num%2=1); for(a=2;a=num/2+1;a+) if(prime(a) & prime(/*/( num-a) /*/) printf(n %d = %d + %d , num, a, num-a);第三套卷*ccon031.c#include #include /*/ main() /*/ float x,x0,f,f1; x=1.5; do x0=x; f=(2*x0-4)*x0+3)*x0-6;
13、f1=(6*x0-8)*x0+3; x=x0-f/f1; /*/ while /*/(fabs(x-x0)=1e-6); printf(the root is: %.2fn,x);*ccon032.c#include void main() char s80; int i; printf(Please input a string: ); for(i=0;(si=getchar()!=n)&(i=a&si=A&si=Z /*/) si=si+32; printf(%c,si); *ccon033.c#include float average(int *pa,int n) int k; /*/
14、 float avg=0; /*/ for(k=0;kn;k+) avg = avg+/*/ pa /*/; avg = avg/n; return avg;void main() int a5=20,30,45,64,23; float m; m=average(/*/ a /*/, 5); printf(Average=%fn,m);模拟卷*calfun.c#include #include void main() int x; /*/ float f; /*/ printf(Input an integer: ); scanf(%d,&x); f = /*/ (abs(x)-2.0)/(
15、x*x+1.0) /*/ ; printf(F(x)=%fn,f); getch();*intsum.c#include void main() int n,a,b; /*/a=0; b=0; /*/ scanf(%d,&n); while(/*/n /*/) if(n%2=0) a+=n; /*/ else b+=n /*/ scanf(%d,&n); printf(Sum of even number: %d, Sum of odd number: %dn,a,b);*fac.c#include void main() int n,i; double s,fac;/*/ s=0; fac=
16、1; /*/ scanf(%d,&n); for(i=1;i=n;i+) fac=/*/ fac/i /*/; s=s+fac; printf(%fn,s);*第四部分:编程题(每题10分)第一套卷*cprog011.c#include #include double fun1(double x) /*/ /*/ void main() clrscr(); printf(fun1(0.76) = %8.3lfn, fun1(0.76); printf(fun1(3.00) = %8.3lfn, fun1(3.00); printf(fun1(3.76) = %8.3lfn, fun1(3.76
17、);*cprog012.c#include #include #include #include int fun2(int a,int n,int b,int c) /*/ /*/ void main() int n = 10, i, nb; int aa10 = 12, -10, -31, -18, -15, 50, 17, 15, -20, 20; int bb10, cc10; clrscr(); printf(There are %2d elements in aa.n, n); printf(They are: ); for(i=0; in; i+) printf(%6d, aai)
18、; printf(n); nb = fun2(aa, n, bb, cc); printf(Elements in bb are: ); for (i=0; inb; i+) printf(%6d, bbi); printf(n); printf(Elements in cc are: ); for(i=0; inb; i+) printf(%6d, cci); printf(n); printf(There are %2d elements in bb.n, nb);第二套卷*cporg021.c#include #include double fun1(double x) /*/ /*/v
19、oid main() clrscr(); printf(fun1(0.76) = %8.3lfn, fun1(0.76); printf(fun1(3.00) = %8.3lfn, fun1(3.00); printf(fun1(3.76) = %8.3lfn, fun1(3.76);*cprog022.c#include #include #include #include void fun2(char a,char b,char c)/*/*/void main() char str115=Fuzhou,str215=Fujian,str315=China; clrscr(); fun2(
20、str1,str2,str3); printf(The ordered strings is : %s, %s, %sn,str1,str2,str3); getch();第三套卷*cprog031.c#include #include double fun1(double x) /*/ /*/ void main() clrscr(); printf(fun1(0.76) = %8.3lfn, fun1(0.76); printf(fun1(3.00) = %8.3lfn, fun1(3.00); printf(fun1(3.76) = %8.3lfn, fun1(3.76);*cprog0
21、32.c#include int fun(char *s) /*/ /*/void main() char str255; gets(str); printf(%dn,fun(str);模拟卷*section.c#include void main() float x,y; printf(enter x:); scanf(%f,&x); /*/ if(x=1) y=x+5; else if(x=10) y=2*x; else y=3/(x-10); /*/ printf(x=%.2f,y=%.2fn,x,y);*sort.c#include void sort(int a,int n) /*/k=i; for(j=i+1;jn;j+) if(ajak) k=j; if(k!=i) t=ai;ai=ak;ak=t; /*/void main( ) int a10=6,3,12,0,2,10,i; sort(a,6); printf(the sorted array a: n); for(i=0;i6;i+) printf(%4d,ai); printf(n);