【计算机类职业资格】国家二级(C语言)机试-试卷77及答案解析.doc

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

1、国家二级(C 语言)机试-试卷 77 及答案解析(总分:12.00,做题时间:90 分钟)一、程序填空题(总题数:2,分数:4.00)1.程序填空题()(分数:2.00)_2.给定程序通过定义并赋初值的方式,利用结构体变量存储了一名学生的学号、姓名和 3 门课的成绩。函数 fun 的功能是将该学生的各科成绩都乘以一个系数 a。 请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。 注意:源程序存放在考生文件夹下的 BLANKlC 中。 不得增行或删行,也不得更改程序的结构! #include typedef struct int num; char name9; float

2、score3; STU; void show(STU tt) int i; printf(“%d %s : “,tt.num,tt.name); for(i=0; i【2】 *=a; main() STU std= 1,“Zhanghua“,76.5,78.0,82.0 ; float a; printf(“/nThe original number and name and scores :/n“); show(std); printf(“/nInput a number : “); scanf(“%f“, /*found*/ modify(【3】,a); printf(“/nA resul

3、t of modifying :/n“); show(std); (分数:2.00)_二、程序修改题(总题数:2,分数:4.00)3.程序修改题()(分数:2.00)_4.给定程序 MODllC 是建立一个带头结点的单向链表,并用随机函数为各结点赋值。函数 fun 的功能是将单向链表结点(不包括头结点)数据域为偶数的值累加起来,并且作为函数值返回。 请改正函数 fun 中指定部位的错误,使它能得出正确能结果。 注意:不要改动 main 函数,不得增行或删行,也不得更改程序的结构! #include #include typedef struct aa int data; struct aa *

4、next;NODE; int fun(NODE *h) int sum = 0 ; NODE *p; /*found*/ p=h;-next; while(p) if(p-data%2=0) sum +=p-data; /*found*/ p=p-next; return sum; NODE *creatlink(int n) NODE *h, *p, *s; int i; h=p=(NODE *)malloc(sizeof(NODE); for(i=1; idata=rand()%16; s-next=p-next; p-next=s; p=p-next; p-next=NULL; retu

5、rn h; outlink(NODE *h, FILE *pf) NODE *p; p = h-next; fprintf(pf ,“/n/nTHE LIST :/n/n HEAD “); while(p) fprintf(pf ,“-%d “,p-data); p=p-next; fprintf (pf,“/n“); outresult(int s, FILE *pf) fprintf(pf,“/nThe sum of even numbers : %d/n“,s); main() NODE *head; int even; head=creatlink(12); head-data=900

6、0; outlink(head , stdout); even=fun(head); printf(“/nThe result :/n“); outresult(even, stdout); (分数:2.00)_三、程序设计题(总题数:2,分数:4.00)5.程序设计题()(分数:2.00)_6.请编写函数 fun,函数的功能是;将 M 行 N 列的二维数组中的数据,按行的顺序依次放到一维数组中,一维数组中数据的个数存放在形参 n 所指的存储单元中。 例如,二维数组中的数据为: (分数:2.00)_国家二级(C 语言)机试-试卷 77 答案解析(总分:12.00,做题时间:90 分钟)一、程序

7、填空题(总题数:2,分数:4.00)1.程序填空题()(分数:2.00)_解析:2.给定程序通过定义并赋初值的方式,利用结构体变量存储了一名学生的学号、姓名和 3 门课的成绩。函数 fun 的功能是将该学生的各科成绩都乘以一个系数 a。 请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。 注意:源程序存放在考生文件夹下的 BLANKlC 中。 不得增行或删行,也不得更改程序的结构! #include typedef struct int num; char name9; float score3; STU; void show(STU tt) int i; printf(“

8、d %s : “,tt.num,tt.name); for(i=0; i【2】 *=a; main() STU std= 1,“Zhanghua“,76.5,78.0,82.0 ; float a; printf(“/nThe original number and name and scores :/n“); show(std); printf(“/nInput a number : “); scanf(“%f“, /*found*/ modify(【3】,a); printf(“/nA result of modifying :/n“); show(std); (分数:2.00)_正确答

9、案:(正确答案:STU scorei ”。 第三空:modify 函数的第一个参数是指针,故调用该函数时第一个参数应该是变量 std 的地址“ struct aa *next;NODE; int fun(NODE *h) int sum = 0 ; NODE *p; /*found*/ p=h;-next; while(p) if(p-data%2=0) sum +=p-data; /*found*/ p=p-next; return sum; NODE *creatlink(int n) NODE *h, *p, *s; int i; h=p=(NODE *)malloc(sizeof(NO

10、DE); for(i=1; idata=rand()%16; s-next=p-next; p-next=s; p=p-next; p-next=NULL; return h; outlink(NODE *h, FILE *pf) NODE *p; p = h-next; fprintf(pf ,“/n/nTHE LIST :/n/n HEAD “); while(p) fprintf(pf ,“-%d “,p-data); p=p-next; fprintf (pf,“/n“); outresult(int s, FILE *pf) fprintf(pf,“/nThe sum of even

11、 numbers : %d/n“,s); main() NODE *head; int even; head=creatlink(12); head-data=9000; outlink(head , stdout); even=fun(head); printf(“/nThe result :/n“); outresult(even, stdout); (分数:2.00)_正确答案:(正确答案:p=h-next; p=p- next;)解析:解析:(1)根据题干中求得除了头结点之外的结点数据域中的最大值,头指针 h,工作指针 p 指向头结点的下一个结点,所以第一个标识下的“p=h;”指向头结

12、点应该改为指向下一个结点“p=h-next;”。 (2)工作指针 p,利用 p 实现对链表的遍历,p 表示指向链表的当前结点,所以指向下一个结点应该是“p=p- next;”。三、程序设计题(总题数:2,分数:4.00)5.程序设计题()(分数:2.00)_解析:6.请编写函数 fun,函数的功能是;将 M 行 N 列的二维数组中的数据,按行的顺序依次放到一维数组中,一维数组中数据的个数存放在形参 n 所指的存储单元中。 例如,二维数组中的数据为: (分数:2.00)_正确答案:(正确答案: int i,j; for(i=0;i解析:解析:(1)利用两重循环,依次取矩阵中的元素。 (2)其中注意指针数组与数组指针的区别,其中数组指针 s,它指向包含 4 个元素的一维数组。其数据元素的表示方式为:“*(*(s+i)+j)”。

展开阅读全文
相关资源
猜你喜欢
  • DIN EN 6069-2011 Aerospace series - Rivet 100 reduced flush head close tolerance - Inch series German and English version EN 6069 2009《航空航天系列 紧公差100缩减埋头铆钉 英制系列 德文和英文版本EN 6069-2009》.pdf DIN EN 6069-2011 Aerospace series - Rivet 100 reduced flush head close tolerance - Inch series German and English version EN 6069 2009《航空航天系列 紧公差100缩减埋头铆钉 英制系列 德文和英文版本EN 6069-2009》.pdf
  • DIN EN 607-2005 Eaves gutters and fittings made of PVC-U - Definitions requirements and testing German version EN 607 2004《未增塑聚氯乙烯制屋檐沟和附件 定义、要求和检验》.pdf DIN EN 607-2005 Eaves gutters and fittings made of PVC-U - Definitions requirements and testing German version EN 607 2004《未增塑聚氯乙烯制屋檐沟和附件 定义、要求和检验》.pdf
  • DIN EN 6072-2011 Aerospace series - Metallic materials - Test methods - Constant amplitude fatigue testing German and English version EN 6072 2010《航空航天系列 金属材料 试验方法 横幅疲劳试验 德文版本和英文版本.pdf DIN EN 6072-2011 Aerospace series - Metallic materials - Test methods - Constant amplitude fatigue testing German and English version EN 6072 2010《航空航天系列 金属材料 试验方法 横幅疲劳试验 德文版本和英文版本.pdf
  • DIN EN 6075-2017 Aerospace series - Static seal elements O-Ring ethylene-propylene moulded phosphate ester resistant (- 55 C to 107 C) - Inch series German and English version EN 6.pdf DIN EN 6075-2017 Aerospace series - Static seal elements O-Ring ethylene-propylene moulded phosphate ester resistant (- 55 C to 107 C) - Inch series German and English version EN 6.pdf
  • DIN EN 6076-2017 Aerospace series - Static seal elements O-Ring for straight thread tube fitting boss ethylene-propylene moulded phosphate ester resistant (-55 C to 107 C) - Inch s.pdf DIN EN 6076-2017 Aerospace series - Static seal elements O-Ring for straight thread tube fitting boss ethylene-propylene moulded phosphate ester resistant (-55 C to 107 C) - Inch s.pdf
  • DIN EN 6080-2016 Aerospace series - Rivet 100 normal flush head close tolerance - Inch series German and English version EN 6080 2016《航空航天系列 100紧公差正常平头铆钉 英制系列 德文和英文版本EN 6080-2016》.pdf DIN EN 6080-2016 Aerospace series - Rivet 100 normal flush head close tolerance - Inch series German and English version EN 6080 2016《航空航天系列 100紧公差正常平头铆钉 英制系列 德文和英文版本EN 6080-2016》.pdf
  • DIN EN 6081-2016 Aerospace series - Rivet universal head close tolerance - Inch series German and English version EN 6081 2016《航空航天系列 100紧公差通用头铆钉 英制系列 德文和英文版本EN 6081-2016》.pdf DIN EN 6081-2016 Aerospace series - Rivet universal head close tolerance - Inch series German and English version EN 6081 2016《航空航天系列 100紧公差通用头铆钉 英制系列 德文和英文版本EN 6081-2016》.pdf
  • DIN EN 609-1-2017 Agricultural and forestry machinery - Safety of log splitters - Part 1 Wedge splitters German version EN 609-1 2017《农林机械 劈木机的安全性 第1部分 楔形劈木机 德文版本EN 609-1-2017》.pdf DIN EN 609-1-2017 Agricultural and forestry machinery - Safety of log splitters - Part 1 Wedge splitters German version EN 609-1 2017《农林机械 劈木机的安全性 第1部分 楔形劈木机 德文版本EN 609-1-2017》.pdf
  • DIN EN 609-2-2010 en 4518 Agricultural and forestry machinery - Safety of log splitters - Part 2 Screw splitters German version EN 609-2 1999+A1 2009《农业和林业机械 原木切割机的安全性 第2部分 螺旋切割机 德.pdf DIN EN 609-2-2010 en 4518 Agricultural and forestry machinery - Safety of log splitters - Part 2 Screw splitters German version EN 609-2 1999+A1 2009《农业和林业机械 原木切割机的安全性 第2部分 螺旋切割机 德.pdf
  • 相关搜索

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

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