电子文档交易市场
安卓APP | ios版本
电子文档交易市场
安卓APP | ios版本

全过计算机等级考试二级C语言机试题库最新

270页
  • 卖家[上传人]:lcm****801
  • 文档编号:43151624
  • 上传时间:2018-06-04
  • 文档格式:DOC
  • 文档大小:696KB
  • / 270 举报 版权申诉 马上下载
  • 文本预览
  • 下载提示
  • 常见问题
    • 1、第 1 套给定程序的功能是调用 fun 函数建立班级通讯录。通讯录中记录每位学生的编号、姓 名和电话号码。班级的人数和学生的信息从键盘读入,每个人的信息作为一个数据块写到名 为 myfile5.dat 的二进制文件中。请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。#include #include #define N 5 typedef struct int num;char name10;char tel10; STYPE; void check();/*found*/ 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)

      2、 main() int a,b; long c;void NONO ( );printf(“Input a, b:“); scanf(“%d,%d“, fun(a, b, printf(“The result is: %dn“, c);NONO();填空题参考答案:1) int fun(STYPE *std)2) FILE *fp; int i;3) fwrite( 修改题参考答案:1) for(i = 0 ; i #include #include void WriteText(FILE *); void ReadText(FILE *); 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 Writ

      3、eText(FILE _1_) char str81;printf(“nEnter string with -1 to end :n“);gets(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); 给定程序 MODI1.C 中函数 fun 的功能是:从低位开始取出长整型变量 s 中奇数位上的数, 依次构成一个新数放在 t 中。高位仍在高位,低位仍在低位。例如,当 s 中的数为:7654321 时,t 中的数为:7531。请改正程序中的错误,使它能得出正确的结果。注意:不要改动 main 函数,不得增行或删行,也不得更改程序的结构!#include /*found

      4、*/ 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(“nPlease enter s:“); scanf(“%ld“, fun(s, printf(“The result is: %ldn“, t); 函数 fun 的功能是:将两个两位数的正整数 a、b 合并形成一个整数放在 c 中。合并的 方式是:将 a 数的十位和个位数依次放在 c 数的个位和百位上, b 数的十位和个位数依次放在 c 数的千位和十位上。例如,当 a45,b=12 时,调用该函数后,c=1524。注意: 部分源程序存在文件 PROG1.C 中。数据文件 IN.DAT 中的数据不得修改。请勿改动主函数 main 和其它函数中的任何内容,仅在函数 fun 的花括号中填入你编写 的若干语句。#include void fun(int a, int b, long *c) main() int

      5、 a,b; long c;void NONO ( );printf(“Input a, b:“);scanf(“%d,%d“, fun(a, b, printf(“The result is: %ldn“, c);NONO(); 填空题参考答案:1) void WriteText(FILE *fw)2) fputs(str,fw); fputs(“n“,fw);3) printf(“%s“,str); 修改题参考答案:1) void fun (long s, long *t)2) sl = sl*10; 程序题参考答案:void fun(int a, int b, long *c) *c=(b/10)*1000+(a%10)*100+(b%10)*10+(a/10);第 3 套给定程序中,函数 fun 的功能是:将自然数 110 以及它们的平方根写到名为 myfile3.txt 的文本文件中,然后再顺序读出显示在屏幕上。请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。注意:源程序存放在考生文件夹下的 BLANK1.C 中。不得增行或删行,也不得更改程序的结构!#i

      6、nclude #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 fun ( int n, int *a ) int i, j, p, t;for ( j = 0; jai ) /*found*/t=i;if ( p!=j ) t = aj; aj = ap; ap = t; 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(); 填空题参考答案:1) fprintf(fp,“%d %fn“,i,sqrt(double)i);2) fclose(fp);3) if(f

      7、p=fopen(fname,“r“)=NULL) 修改题参考答案:1) for ( i=j+1; 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); /*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 :

      8、n“);for(i=1; ivoid fun (long s, long *t) int d;long 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); 函数 fun 的功能是:将两个两位数的正整数 a、b 合并形成一个整数放在 c 中。合并的 方式是:将 a 数的十位和个位数依次放在 c 数的十位和千位上, b 数的十位和个位数依次 放在 c 数的百位和个位上。例如,当 a45,b=12 时,调用该函数后,c=5142。注意: 部分源程序存在文件 PROG1.C 中。数据文件 IN.DAT 中的数据不得修改。请勿改动主函数 main 和其它函数中的任何内容,仅在函数 fun 的花括号中填入你编写 的若干语句。#include 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(); 填空题参考答案:1) if(fs=fopen(source, “r“)=NULL)2) while(!feof(fs)3) fputc(ch,ft); 修改题参考答案:1) if (d%2=0)2) s /= 10; 程序题参考答案:void fun(int a, int b, long *c) *c=(a%10)*1000+(b/10)*100+(a/10)*10+(b%10); 第 5 套给定程序中已建立一个带有头结点的单向

      《全过计算机等级考试二级C语言机试题库最新》由会员lcm****801分享,可在线阅读,更多相关《全过计算机等级考试二级C语言机试题库最新》请在金锄头文库上搜索。

      点击阅读更多内容
    关于金锄头网 - 版权申诉 - 免责声明 - 诚邀英才 - 联系我们
    手机版 | 川公网安备 51140202000112号 | 经营许可证(蜀ICP备13022795号)
    ©2008-2016 by Sichuan Goldhoe Inc. All Rights Reserved.