【计算机类职业资格】三级数据库技术机试-253及答案解析.doc

上传人:arrownail386 文档编号:1321291 上传时间:2019-10-17 格式:DOC 页数:5 大小:29KB
下载 相关 举报
【计算机类职业资格】三级数据库技术机试-253及答案解析.doc_第1页
第1页 / 共5页
【计算机类职业资格】三级数据库技术机试-253及答案解析.doc_第2页
第2页 / 共5页
【计算机类职业资格】三级数据库技术机试-253及答案解析.doc_第3页
第3页 / 共5页
【计算机类职业资格】三级数据库技术机试-253及答案解析.doc_第4页
第4页 / 共5页
【计算机类职业资格】三级数据库技术机试-253及答案解析.doc_第5页
第5页 / 共5页
亲,该文档总共5页,全部预览完了,如果喜欢就下载吧!
资源描述

1、三级数据库技术机试-253 及答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.对 10 个候选人进行选举,现有一个 100 条记录的选票文件 IN84.DAT,其数据存放格式是每条记录的长度均为 10 位,第一位表示第一个人的选中情况,第二位表示第二个人的选中情况,依此类推。每一位候选人的记录内容均为字符 O 或 1,1 表示此人被选中,0 表示此人未被选中,若一张选票选中人数大于 5个人时被认为无效的选票。给定函数 ReadDat()的功能是把选票数据读入到字符串数组 xx 中。请编制函数 CoutRs()来统计每个人的选票数并把得票数依次

2、存入 yy0到 yy9中,最后调用函数 WfiteDat()把结果”输出到文件 OUT84.DAT 中。注意:部分源程序已给出。请勿改动主函数 main()、读函数 ReadDat()和写函数 WfiteDat()的内容。试题程序:#includeStdiohchar xx10011;int YY10;int ReadDat(void);void WriteDat(void);void C0utRs(void)void main()int i;for(i=0;i10;i+)yyi=0;if(ReadDat()printf (“数据文件 IN84.DAT 不能打开! /n/007“ );retu

3、rn;CoutRs();.WriteDat();int ReadDat(void)FILE *fp;int i;char tt13;if(fp=fopen(“IN84.DAT“,“r“ )=NULL) return 1;for(i=0;i100;i+)if(fgets(tt,13,fp)=NULL) return 1;memcpy(xxi,tt,10);xxi 10=0;fclose(fp);return 0;void WriteDat)FILE *fp;int i;fp= foDen(“OUT84.DAT“,“w“);for(i=0;i10;i+)fprintf( fp, “%dkn“, y

4、y i );printf(,“第%d 个人的选票数=%d/n“, i+1,yy i );fclose(fp);(分数:100.00)_三级数据库技术机试-253 答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.对 10 个候选人进行选举,现有一个 100 条记录的选票文件 IN84.DAT,其数据存放格式是每条记录的长度均为 10 位,第一位表示第一个人的选中情况,第二位表示第二个人的选中情况,依此类推。每一位候选人的记录内容均为字符 O 或 1,1 表示此人被选中,0 表示此人未被选中,若一张选票选中人数大于 5个人时被认为无效的选票。给定

5、函数 ReadDat()的功能是把选票数据读入到字符串数组 xx 中。请编制函数 CoutRs()来统计每个人的选票数并把得票数依次存入 yy0到 yy9中,最后调用函数 WfiteDat()把结果”输出到文件 OUT84.DAT 中。注意:部分源程序已给出。请勿改动主函数 main()、读函数 ReadDat()和写函数 WfiteDat()的内容。试题程序:#includeStdiohchar xx10011;int YY10;int ReadDat(void);void WriteDat(void);void C0utRs(void)void main()int i;for(i=0;i1

6、0;i+)yyi=0;if(ReadDat()printf (“数据文件 IN84.DAT 不能打开! /n/007“ );return;CoutRs();.WriteDat();int ReadDat(void)FILE *fp;int i;char tt13;if(fp=fopen(“IN84.DAT“,“r“ )=NULL) return 1;for(i=0;i100;i+)if(fgets(tt,13,fp)=NULL) return 1;memcpy(xxi,tt,10);xxi 10=0;fclose(fp);return 0;void WriteDat)FILE *fp;int

7、i;fp= foDen(“OUT84.DAT“,“w“);for(i=0;i10;i+)fprintf( fp, “%dkn“, yy i );printf(,“第%d 个人的选票数=%d/n“, i+1,yy i );fclose(fp);(分数:100.00)_正确答案:(void CoutRs (void)int i,count, j;char *pf;for (i=0; i10;i+)yyi =0; for (i=0; i100; i+)pf=xxi; /*指针 pf 指向字符串的第一个字符* /count=0;while (*pr)if (*Df= 1)count+; /*统计每条记

8、录中 1 的个数*/pf+;else pf+;if (count=5) /*如果每条记录中 1 的个数小于等于 5 则为有效票*/ pf=xx i; /*指针 pf 指向字符串的第一个字符*/j=0;while (*pf) /*统计每个人的选票数并把得票数依次存入 yy 0到 yy 9 中*/if (*pf=1)yyj+=1;j+;pf+;else if(*pf=0)j+;pf+;)解析:解析 本题考查的知识点如下:(1)二维数组的操作。(2)指向数组的指针。在本题中,要先判断选票是否有效。因为记录存放在一个二维数组中,为了简便我们为数组的一组元素定义一个指向该数组每一行数据的指针,例如,chaf*p=xx2。初始时该指针指向该行的第一个元素,指针地址每加 1,则指向下一个元素。这样就可以轻松地统计每一个选票。设一变量标记每一个选票中 1 的个数,若其不大于 5,则选票有效。若选票有效,则依次查看哪一个元素为 1,在数组”相应的元素上加 1。使用循环实现对所有记录的访问。

展开阅读全文
相关资源
猜你喜欢
  • EN 1097-6-2013 en Tests for mechanical and physical properties of aggregates - Part 6 Determination of particle density and water absorption《集料的机械和物理特性试验 第6部分 颗粒密度和吸水性的测定》.pdf EN 1097-6-2013 en Tests for mechanical and physical properties of aggregates - Part 6 Determination of particle density and water absorption《集料的机械和物理特性试验 第6部分 颗粒密度和吸水性的测定》.pdf
  • EN 1097-7-2008 en Tests for mechanical and physical properties of aggregates - Part 7 Determination of the particle density of filler - Pyknometer method《集料的机械和物理性能试验 第7部分 填料颗粒密度的测.pdf EN 1097-7-2008 en Tests for mechanical and physical properties of aggregates - Part 7 Determination of the particle density of filler - Pyknometer method《集料的机械和物理性能试验 第7部分 填料颗粒密度的测.pdf
  • EN 1097-8-2009 en Tests for mechanical and physical properties of aggregates - Part 8 Determination of the polished stone value《骨料的机械和物理特性试验 第8部分 石料磨光值的测定》.pdf EN 1097-8-2009 en Tests for mechanical and physical properties of aggregates - Part 8 Determination of the polished stone value《骨料的机械和物理特性试验 第8部分 石料磨光值的测定》.pdf
  • EN 1097-9-2014 en Tests for mechanical and physical properties of aggregates - Part 9 Determination of the resistance to wear by abrasion from studded tyres - Nordic test《集料力学性能和物理.pdf EN 1097-9-2014 en Tests for mechanical and physical properties of aggregates - Part 9 Determination of the resistance to wear by abrasion from studded tyres - Nordic test《集料力学性能和物理.pdf
  • EN 1101-1995 en Textiles and textile products Burning behaviour Curtains and drapes Detailed procedure to determine the ignitability of vertically oriented specimens (small flame) .pdf EN 1101-1995 en Textiles and textile products Burning behaviour Curtains and drapes Detailed procedure to determine the ignitability of vertically oriented specimens (small flame) .pdf
  • EN 1102-1995 Textiles and Textile Products - Burning Behaviour - Curtains and Drapes - Detailed Procedure to Determine the Flame Spread of Vertically Oriented Specimens《纺织品和纺织产品 燃烧.pdf EN 1102-1995 Textiles and Textile Products - Burning Behaviour - Curtains and Drapes - Detailed Procedure to Determine the Flame Spread of Vertically Oriented Specimens《纺织品和纺织产品 燃烧.pdf
  • EN 1102-2016 en Textiles and Textile Products - Burning Behaviour - Curtains and Drapes - Detailed Procedure to Determine the Flame Spread of Vertically Oriented Specimens《纺织品和纺织产品.pdf EN 1102-2016 en Textiles and Textile Products - Burning Behaviour - Curtains and Drapes - Detailed Procedure to Determine the Flame Spread of Vertically Oriented Specimens《纺织品和纺织产品.pdf
  • EN 1103-2005 en Textiles - Fabrics for apparel - Detailed procedure to determine the burning behaviour《纺织品 服装织物 燃烧性能的测定用详细程序》.pdf EN 1103-2005 en Textiles - Fabrics for apparel - Detailed procedure to determine the burning behaviour《纺织品 服装织物 燃烧性能的测定用详细程序》.pdf
  • EN 1104-2005 en Paper and Board Intended to Come into Contact with Foodstuffs - Determination of Transfer of Antimicrobic Constituents《与食品接触的纸和纸板 抗微生物成分转移的测定》.pdf EN 1104-2005 en Paper and Board Intended to Come into Contact with Foodstuffs - Determination of Transfer of Antimicrobic Constituents《与食品接触的纸和纸板 抗微生物成分转移的测定》.pdf
  • 相关搜索

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

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