2012c语言考试试题外泄题库

上传人:j****9 文档编号:45994855 上传时间:2018-06-20 格式:DOC 页数:80 大小:1.14MB
返回 下载 相关 举报
2012c语言考试试题外泄题库_第1页
第1页 / 共80页
2012c语言考试试题外泄题库_第2页
第2页 / 共80页
2012c语言考试试题外泄题库_第3页
第3页 / 共80页
2012c语言考试试题外泄题库_第4页
第4页 / 共80页
2012c语言考试试题外泄题库_第5页
第5页 / 共80页
点击查看更多>>
资源描述

《2012c语言考试试题外泄题库》由会员分享,可在线阅读,更多相关《2012c语言考试试题外泄题库(80页珍藏版)》请在金锄头文库上搜索。

1、 第01套:给定程序的功能是调用fun函数建立班级通讯录。通讯录中记录每位学生的 编号、姓名和电话号码。班级的人数和学生的信息从键盘读入,每个人的信息作 为一个数据块写到名为myfile5.dat的二进制文件中。请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结 果。注意:源程序存放在考生文件夹下的BLANK1.C中。不得增行或删行,也不得更改程序的结构!给定源程序: #include #include #define N 5 typedef struct int num;char name10;char tel10; STYPE; void check();/*found*/

2、 int fun(_1_ *std) /*found*/_2_ *fp; int i;if(fp=fopen(“myfile5.dat“,“wb“)=NULL)return(0);printf(“nOutput data to file !n“);for(i=0; i #include void fun (char *s, char *t) int i, sl;sl = strlen(s); /*found*/for( i=0; i void fun(int a, int b, long *c) main() int a,b; long c;void NONO ( );printf(“Inpu

3、t a b:“); scanf(“%d%d“, fun(a, b, printf(“The result is: %dn“, c);NONO(); void NONO ( ) /* 本函数用于打开文件,输入数据,调用函数,输出数据,关闭文件。 */FILE *rf, *wf ;int i, a,b ; long c ;rf = fopen(“c:testin.dat“, “r“) ;wf = fopen(“c:testout.dat“,“w“) ;for(i = 0 ; i #include #include void WriteText(FILE *); void ReadText(FILE

4、 *); main() FILE *fp;if(fp=fopen(“myfile4.txt“,“w“)=NULL) printf(“ open fail!n“); exit(0); WriteText(fp);fclose(fp);if(fp=fopen(“myfile4.txt“,“r“)=NULL) printf(“ open fail!n“); exit(0); ReadText(fp);fclose(fp); /*found*/void WriteText(FILE _1_) char str81;printf(“nEnter string with -1 to end :n“);ge

5、ts(str);while(strcmp(str,“-1“)!=0) /*found*/fputs(_2_,fw); fputs(“n“,fw);gets(str); void ReadText(FILE *fr) char str81;printf(“nRead file and output to screen :n“);fgets(str,81,fr);while( !feof(fr) ) /*found*/printf(“%s“,_3_);fgets(str,81,fr); 【微答案】 (1) *fw (2) str (3) str/*/ 给定程序MODI1.C中函数fun的功能是:从

6、低位开始取出长整型变量s中奇数位 上的数,依次构成一个新数放在t中。高位仍在高位,低位仍在低位。例如,当s中的数为:7654321时,t中的数为:7531。请改正程序中的错误,使它能得出正确的结果。注意:不要改动main函数,不得增行或删行,也不得更改程序的结构!给定源程序: #include /*found*/ void fun (long s, long t) long sl=10;*t = s % 10;while ( s 0) s = s/100;*t = s%10 * sl + *t; /*found*/sl = sl*100;main() long s, t;printf(“nPl

7、ease enter s:“); scanf(“%ld“, fun(s, printf(“The result is: %ldn“, t); 【微答案】 (1)void fun(long s,long *t) (2)sl=sl*10;/*/ 学生的记录由学号和成绩组成,N名学生的数据已在主函数中放入结构体数组 s中, 请编写函数fun,它的功能是:把分数最低的学生数据放在b所指的数组中,注意:分数最低的学生可能不止一个,函数返回分数最低的学生的人数。注意: 部分源程序在文件PROG1.C文件中。请勿改动主函数main和其它函数中的任何内容,仅在函数fun的花括号中填 入 你编写的若干语句。给定

8、源程序: #include #define N 16 typedef struct char num10;int s; STREC; int fun( STREC *a, STREC *b ) main() STREC sN=“GA05“,85,“GA03“,76,“GA02“,69,“GA04“,85,“GA01“,91,“GA07“,72,“GA08“,64,“GA06“,87,“GA015“,85,“GA013“,91,“GA012“,64,“GA014“,91,“GA011“,91,“GA017“,64,“GA018“,64,“GA016“,72;STREC hN;int i,n;FI

9、LE *out ;n=fun( s,h );printf(“The %d lowest score :n“,n);for(i=0;iai.s) min=ai.s; /*找出最小值*/for(i=0;i #include int fun(char *fname ) FILE *fp; int i,n; float x;if(fp=fopen(fname, “w“)=NULL) return 0;for(i=1;i #include void fun ( int n, int *a ) int i, j, p, t;for ( j = 0; jai ) /*found*/t=i;if ( p!=j

10、 ) t = aj; aj = ap; ap = t; void putarr( int n, int *z ) int i;for ( i = 1; i void fun(int a, int b, long *c) main() int a,b; long c;void NONO ( );printf(“Input a b:“);scanf(“%d%d“, fun(a, b, printf(“The result is: %ldn“, c);NONO(); void NONO ( ) /* 本函数用于打开文件,输入数据,调用函数,输出数据,关闭文件。 */FILE *rf, *wf ;in

11、t i, a,b ; long c ;rf = fopen(“c:testin.dat“, “r“) ;wf = fopen(“c:testout.dat“,“w“) ;for(i = 0 ; i #include int fun(char *source, char *target) FILE *fs,*ft; char ch; /*found*/if(fs=fopen(source, _1_)=NULL)return 0;if(ft=fopen(target, “w“)=NULL)return 0;printf(“nThe data in file :n“);ch=fgetc(fs); /

12、*found*/while(!feof(_2_) putchar( ch ); /*found*/fputc(ch,_3_);ch=fgetc(fs);fclose(fs); fclose(ft);printf(“nn“);return 1; main() char sfname20 =“myfile1“,tfname20=“myfile2“;FILE *myf; int i; char c;myf=fopen(sfname,“w“);printf(“nThe original data :n“);for(i=1; ivoid fun (long s, long *t) int d;long

13、sl=1;*t = 0;while ( s 0) d = s%10; /*found*/if (d%2=0) *t=d* sl+ *t;sl *= 10; /*found*/s = 10; main() long s, t;printf(“nPlease enter s:“); scanf(“%ld“, fun(s, printf(“The result is: %ldn“, t); 【微答案】 (1)if(d%2=0) (2)s/=10; /*/函数fun的功能是: 将s所指字符串中除了下标为偶数、同时ASCII值也为偶 数的字符外,其余的全都删除;串中剩余字符所形成的一个新串放在t所指的数组 中。例如,若s所指字符串中的内容为:“ABCDEFG123456“,其中字符A的ASCII码 值为奇数,因此应当删除;其中字符B的ASCII码值为偶数,但在数组中的下标为 奇数,因此也应当删除;而字符2的ASCII码值为偶数,所在数组中的下标也为偶 数,因此不应当删除,其它依此类推。最后t所指的数组中的内容应是:“246“。注意

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 生活休闲 > 社会民生

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号