资源预览内容
第1页 / 共150页
第2页 / 共150页
第3页 / 共150页
第4页 / 共150页
第5页 / 共150页
第6页 / 共150页
第7页 / 共150页
第8页 / 共150页
第9页 / 共150页
第10页 / 共150页
亲,该文档总共150页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
文档大全 | 借鉴参考collection of questions and answers20XX资源汇编 | 精品资料试卷编号:10194所属语言:Turbo C试卷方案:cxgc试卷总分:1380分共有题型:1种一、程序改错 共138题 (共计1380分)第1题 (10.0分)/*- 【程序改错】-功能:根据整型形参m,计算如下公式的值: y=11/31/51/7.1/(2m-3)-*/#include stdio.hdouble fun(int m) /*FOUND*/ double y=1 int i; /*FOUND*/ for(i=3; im; i+) /*FOUND*/ y+=1.0/(2i-3); return(y);void main(void) int n; clrscr(); printf(Enter n: ); scanf(%d, &n); printf(nThe result is %1fn, fun(n); getch(); 答案: 1). double y=1; 2). for(i=3; i=m; i+) 或 for(i=3; im+1; i+) 3). y+=1.0/(2*i-3);第2题 (10.0分)/*- 【程序改错】-功能:用选择法对数组中的n个元素按从小到大的顺序进行排序。-*/#include #define N 20 void fun(int a, int n) int i, j, t, p; for (j = 0 ;j n-1 ;j+) /*FOUND*/ p = j for (i = j;i ap) /*FOUND*/ p=j; t = ap ; ap = aj ; aj = t; main() int aN=9,6,8,3,-1,i, m = 5; printf(排序前的数据:) ; for(i = 0;i m;i+) printf(%d ,ai); printf(n); fun(a,m); printf(排序后的数据:) ; for(i = 0;i m;i+) printf(%d ,ai); printf(n); getch();答案: 1). p = j; 2). if(ai ai) 3). p = i;第3题 (10.0分)/*- 【程序改错】-功能:编写一个程序,从键盘接收一个字符串,然后按照字符顺 序从小到大进行排序,并删除重复的字符。-*/#include #include void main() char str100,*p,*q,*r,c; printf(输入字符串:); gets(str); /*FOUND*/ for(p=str;p;p+) for(q=r=p;*q;q+) if(*r*q) r=q; /*FOUND*/ if(r=p) /*FOUND*/ c=r; *r=*p; *p=c; for(p=str;*p;p+) for(q=p;*p=*q;q+); strcpy(p+1,q); printf(结果字符串:%snn,str); getch();答案: 1). for(p=str;*p;p+) 2). if(r!=p) 3). c=*r;第4题 (10.0分)/*- 【程序改错】-功能:编写程序, 求矩阵(3行3列)与5的乘积例如:输入下面的矩阵: 100 200 300 400 500 600 700 800 900 程序输出: 500 1000 1500 2000 2500 3000 3500 4000 4500-*/#include stdio.hint fun(int array33) /*FOUND*/ int i;j; /*FOUND*/ for(i=1; i 3; i+) for(j=0; j 3; j+) /*FOUND*/ arrayij=arrayij/5;main() int i,j; int array33=100,200,300, 400,500,600, 700,800,900; clrscr() ; for (i=0; i 3; i+) for (j=0; j 3; j+) printf(%7d,arrayij); printf(n); fun(array); printf(Converted array:n); for (i=0; i 3; i+) for (j=0; j 3; j+) printf(%7d,arrayij); printf(n); getch(); 答案: 1). int i,j; 2). for(i=0; i 3; i+) 3). arrayij=arrayij*5;第5题 (10.0分)/*- 【程序改错】-功能:用起泡法对连续输入的十个字符排序后按从小到大的次序 输出.-*/#define N 10#include #include main( ) int i; char strN; /*FOUND*/ for(i=0;iN;i+)scanf(%c,stri); /*FOUND*/ sort(strN); for(i=0;iN;i+) printf(%c,stri); printf(n);sort(char strN) int i,j; char t; for(j=1;jN;j+) /*FOUND*/ for(i=0;iN-j;i-) /*FOUND*/ if(stristri+1) t=stri; stri=stri+1; stri+1=t; 答案: 1). for(i=0;iN;i+)scanf(%c,&stri); 2). sort(str); 3). for(i=0;istri+1) 或 if(stri+1stri)第6题 (10.0分)/*-
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号