【计算机类职业资格】国家二级C语言机试(操作题)模拟试卷447及答案解析.doc

上传人:visitstep340 文档编号:1332258 上传时间:2019-10-17 格式:DOC 页数:3 大小:34KB
下载 相关 举报
【计算机类职业资格】国家二级C语言机试(操作题)模拟试卷447及答案解析.doc_第1页
第1页 / 共3页
【计算机类职业资格】国家二级C语言机试(操作题)模拟试卷447及答案解析.doc_第2页
第2页 / 共3页
【计算机类职业资格】国家二级C语言机试(操作题)模拟试卷447及答案解析.doc_第3页
第3页 / 共3页
亲,该文档总共3页,全部预览完了,如果喜欢就下载吧!
资源描述

1、国家二级 C语言机试(操作题)模拟试卷 447及答案解析(总分:6.00,做题时间:90 分钟)一、程序填空题(总题数:1,分数:2.00)1.程序通过定义学生结构体变量,存储学生的学号、姓名和三门课的成绩。函数 fun的功能是:将形参 a中的数据进行修改,把修改后的数据作为函数值返回主函数进行输出。 例如,若传给形参 a的数据中学号、姓名和三门课的成绩依次是:10001、“ZhangSan”、95、80、88,修改后的数据应为:10002、“LiSi”、96、81、89。 请在程序的下画线处填入正确的内容并将下画线删除,使程序得出正确的结果。 注意:部分源程序给出如下。 不得增行或删行,也不

2、得更改程序的结构! 试题程序: #include stdioh #include stringh struct student long sno; char name10; float score3; ; /*found*/ 【1】 fun(struct student a) int i; asilo=1 00 02; /*found*/ strcpy( 【2】 ,“Lisi“); /*found*/ for(i=0;i 3;i+) 【3】 +=1; return a; main() struct student s=10001,“ ZhangSan“,95,80,8 8),t; int i;

3、 printf(“/n/nThe originaldata:/n“);printf(“/nNo:ld Name:s/n Scores:“,ssno,sname); for(i=0 j i 3; i+) printf(“62f“,sscorei); printf(“/n“); t=fun(s); printf(“/nThe data after modified:/n“); printf(“/nNo:ld Name:s/n Scores:“,tsno,tname); for(i=0;i 3;i+) printf(“62f“,tscorei); printf(“/n“); (分数:2.00)_二、

4、程序修改题(总题数:1,分数:2.00)2.假定整数数列中的数不重复,并存放在数组中。下列给定程序中函数 fun的功能是:删除数列中值为 X的元素,变量 n中存放数列中元素的个数。 请改正程序中的错误,使它能得出正确的结果。 注意:不要改动 main函数,不得增行或删行,也不得更改程序的结构! 试题程序:#include stdioh #define N 2 0fun(int*a,int n,int x) int P=0,i; an=x; while(x!=aP) p=p+1; /*found*/ if(p=n) return一 1; else for(i=P;i n;i+)/*found*/

5、 ai+1=ai; return n1; void main() 2nt wN=一3,0,1,5,7,99,1 0,1 5,3 0,90,x,n,i; n=10; printf(“The original data:/n“); for(i=0;i 13;i+) printf(“5 d“,wi); printf(“/nInput x(to delete):“); Scanf(“d“,&x); printf(“Delete:d/n“,x); n=fun(w,n,x); if(n=一 1) printf(“*No be found!*/n/n“); else printf(“The data aft

6、erdeleted:/n“); for(i:0;i n ; i+) printf(“5d“,wi); printf(“/n/n“); (分数:2.00)_三、程序设计题(总题数:1,分数:2.00)3.编写函数 fun,其功能是:将两个两位数的正整数 a、b 合并成一个整数放在 c中。合并的方式是:将a数的十位和个位数依次放在 c数的个位和百位上,b 数的十位和个位数依次放在 c数的千位和十位上。 例如,当 a =45,b=12 时,调用该函数后,c=1524。 注意:部分源程序给出如下。数据文件 IN DAT 中的数据不得修改。 请勿改动主函数 main和其他函数中的任何内容,仅在函数 fu

7、n的花括号中填入你编写的若干语句。 试题程序:#include conio h #include stdioh void fun (int a,int b,long * c) main () int a, b; long c; printf (“Input a,b:“) ; fun(a,b,&c); printf(“The result is:ld/n“,c);(分数:2.00)_国家二级 C语言机试(操作题)模拟试卷 447答案解析(总分:6.00,做题时间:90 分钟)一、程序填空题(总题数:1,分数:2.00)1.程序通过定义学生结构体变量,存储学生的学号、姓名和三门课的成绩。函数 fu

8、n的功能是:将形参 a中的数据进行修改,把修改后的数据作为函数值返回主函数进行输出。 例如,若传给形参 a的数据中学号、姓名和三门课的成绩依次是:10001、“ZhangSan”、95、80、88,修改后的数据应为:10002、“LiSi”、96、81、89。 请在程序的下画线处填入正确的内容并将下画线删除,使程序得出正确的结果。 注意:部分源程序给出如下。 不得增行或删行,也不得更改程序的结构! 试题程序: #include stdioh #include stringh struct student long sno; char name10; float score3; ; /*foun

9、d*/ 【1】 fun(struct student a) int i; asilo=1 00 02; /*found*/ strcpy( 【2】 ,“Lisi“); /*found*/ for(i=0;i 3;i+) 【3】 +=1; return a; main() struct student s=10001,“ ZhangSan“,95,80,8 8),t; int i; printf(“/n/nThe originaldata:/n“);printf(“/nNo:ld Name:s/n Scores:“,ssno,sname); for(i=0 j i 3; i+) printf(“

10、62f“,sscorei); printf(“/n“); t=fun(s); printf(“/nThe data after modified:/n“); printf(“/nNo:ld Name:s/n Scores:“,tsno,tname); for(i=0;i 3;i+) printf(“62f“,tscorei); printf(“/n“); (分数:2.00)_正确答案:(正确答案:(1)struct student (2)aname (3)ascorei)解析:解析:填空 1:函数定义时,类型标识符指明了本函数的类型,函数的类型实际上是函数返回值的类型。 本题中,用结构类型定义

11、函数类型。 填空 2和填空 3:此处考查结构体变量成员的表示方法,aname 和 ascorei分别表示学生的姓名和成绩。二、程序修改题(总题数:1,分数:2.00)2.假定整数数列中的数不重复,并存放在数组中。下列给定程序中函数 fun的功能是:删除数列中值为 X的元素,变量 n中存放数列中元素的个数。 请改正程序中的错误,使它能得出正确的结果。 注意:不要改动 main函数,不得增行或删行,也不得更改程序的结构! 试题程序:#include stdioh #define N 2 0fun(int*a,int n,int x) int P=0,i; an=x; while(x!=aP) p=

12、p+1; /*found*/ if(p=n) return一 1; else for(i=P;i n;i+)/*found*/ ai+1=ai; return n1; void main() 2nt wN=一3,0,1,5,7,99,1 0,1 5,3 0,90,x,n,i; n=10; printf(“The original data:/n“); for(i=0;i 13;i+) printf(“5 d“,wi); printf(“/nInput x(to delete):“); Scanf(“d“,&x); printf(“Delete:d/n“,x); n=fun(w,n,x); if

13、n=一 1) printf(“*No be found!*/n/n“); else printf(“The data afterdeleted:/n“); for(i:0;i n ; i+) printf(“5d“,wi); printf(“/n/n“); (分数:2.00)_正确答案:(正确答案:(1)if(p=n) return 一 1; (2)ai=ai+1;)解析:解析:(1)需要确定 if条件语句的条件表达式,发现变量 p大写,C 语言中变量是区别大小写的。 (2)删除数列中的元素,删除后,后面的元素依次前移一个位置,因此此处应为 ai=ai+1;。三、程序设计题(总题数:1,分数

14、2.00)3.编写函数 fun,其功能是:将两个两位数的正整数 a、b 合并成一个整数放在 c中。合并的方式是:将a数的十位和个位数依次放在 c数的个位和百位上,b 数的十位和个位数依次放在 c数的千位和十位上。 例如,当 a =45,b=12 时,调用该函数后,c=1524。 注意:部分源程序给出如下。数据文件 IN DAT 中的数据不得修改。 请勿改动主函数 main和其他函数中的任何内容,仅在函数 fun的花括号中填入你编写的若干语句。 试题程序:#include conio h #include stdioh void fun (int a,int b,long * c) main

15、) int a, b; long c; printf (“Input a,b:“) ; fun(a,b,&c); printf(“The result is:ld/n“,c);(分数:2.00)_正确答案:(正确答案:void fun (int a,int b,lang*c) /*b 10 获取 b的个位,a/10 获取 a的十位,a 10 获取 a的个位,b/ 1 0 获取 b的十位*/ *c=a/10+(b 10)* 10+(a10)* 100+(b/10)* 1000; )解析:解析:本题主要的问题是如何取出 a和 b的个位数和十位数,取出后如何表示成 c中相应的位数。由于 a和 b都是只有两位的整数,所以分别对它们除以 10可得到它们的十位数,分别用 10对它们求余可得到它们的个位数。得到后对应乘以 1000、100、10、1 即可得到 c的千位数、百位数、十位数和个位数。注意使用 c时要进行指针运算。

展开阅读全文
相关资源
猜你喜欢
  • BS EN ISO 9241-307-2008 Ergonomics of human-system interaction - Analysis and compliance test methods for electronic visual displays《人-系统间交互的人类工效学 电子视觉显示分析和一致性试验方法》.pdf BS EN ISO 9241-307-2008 Ergonomics of human-system interaction - Analysis and compliance test methods for electronic visual displays《人-系统间交互的人类工效学 电子视觉显示分析和一致性试验方法》.pdf
  • BS EN ISO 9241-333-2017 Ergonomics of human-system interaction Stereoscopic displays using glasses《人机交互人机工程学 使用眼镜的立体显示器》.pdf BS EN ISO 9241-333-2017 Ergonomics of human-system interaction Stereoscopic displays using glasses《人机交互人机工程学 使用眼镜的立体显示器》.pdf
  • BS EN ISO 9241-400-2007 Ergonomics of human-system interaction - Principles and requirements for physical input devices《人机交互作用的人类工效学 物量投入设备的原则和要求》.pdf BS EN ISO 9241-400-2007 Ergonomics of human-system interaction - Principles and requirements for physical input devices《人机交互作用的人类工效学 物量投入设备的原则和要求》.pdf
  • BS EN ISO 9241-420-2011 Ergonomics of human-system interaction Selection of physical input devices《人机交互作用的人类工效学 物理输入装置的选择》.pdf BS EN ISO 9241-420-2011 Ergonomics of human-system interaction Selection of physical input devices《人机交互作用的人类工效学 物理输入装置的选择》.pdf
  • BS EN ISO 9241-5-1999 Ergonomic requirements for office work with visual display terminals (VDTs) - Workstation layout and postural requirements《具有可视显示终端(VDTs)的办公室工作的人类工效学要求 工作台布置及.pdf BS EN ISO 9241-5-1999 Ergonomic requirements for office work with visual display terminals (VDTs) - Workstation layout and postural requirements《具有可视显示终端(VDTs)的办公室工作的人类工效学要求 工作台布置及.pdf
  • BS EN ISO 9241-6-2000 Ergonomic requirements for office work with visual display terminals (VDTs) - Guidance on the work environment《具有可视显示终端(VDTs)的办公室工作的人类工效学要求 工作环境指南》.pdf BS EN ISO 9241-6-2000 Ergonomic requirements for office work with visual display terminals (VDTs) - Guidance on the work environment《具有可视显示终端(VDTs)的办公室工作的人类工效学要求 工作环境指南》.pdf
  • BS EN ISO 9241-910-2011 Ergonomics of human-system interaction Framework for tactile and haptic interaction《人机交互作用的人类工效学 触觉和触觉交互框架》.pdf BS EN ISO 9241-910-2011 Ergonomics of human-system interaction Framework for tactile and haptic interaction《人机交互作用的人类工效学 触觉和触觉交互框架》.pdf
  • BS EN ISO 9251-1996 Thermal insulation - Heat transfer - Conditions and properties of materials - Vocabulary《隔热 热传导 条件和材料性能 词汇》.pdf BS EN ISO 9251-1996 Thermal insulation - Heat transfer - Conditions and properties of materials - Vocabulary《隔热 热传导 条件和材料性能 词汇》.pdf
  • BS EN ISO 9261-2010 Agricultural irrigation equipment - Emitters and emitting pipe - Specification and test methods《农业灌溉设备 发射源和发射管 试验方法和规范》.pdf BS EN ISO 9261-2010 Agricultural irrigation equipment - Emitters and emitting pipe - Specification and test methods《农业灌溉设备 发射源和发射管 试验方法和规范》.pdf
  • 相关搜索

    当前位置:首页 > 考试资料 > 职业资格

    copyright@ 2008-2019 麦多课文库(www.mydoc123.com)网站版权所有
    备案/许可证编号:苏ICP备17064731号-1