[计算机类试卷]国家三级(网络技术)机试模拟试卷84及答案与解析.doc

上传人:赵齐羽 文档编号:495919 上传时间:2018-11-28 格式:DOC 页数:4 大小:29KB
下载 相关 举报
[计算机类试卷]国家三级(网络技术)机试模拟试卷84及答案与解析.doc_第1页
第1页 / 共4页
[计算机类试卷]国家三级(网络技术)机试模拟试卷84及答案与解析.doc_第2页
第2页 / 共4页
[计算机类试卷]国家三级(网络技术)机试模拟试卷84及答案与解析.doc_第3页
第3页 / 共4页
[计算机类试卷]国家三级(网络技术)机试模拟试卷84及答案与解析.doc_第4页
第4页 / 共4页
亲,该文档总共4页,全部预览完了,如果喜欢就下载吧!
资源描述

1、国家三级(网络技术)机试模拟试卷 84及答案与解析 一、程序设计题 1 对 10个候选人进行选举,现有一个 100条记录的选票文件 IN84.DAT,其数据存放格式是每条记录的长度均为 10位,第一位表示第一个人的选中情况,第二位表示第二个人的选中情况,依此类推。每一位候选人的记录内容均为字符 0或 1,1表示此人被选中, 0表示此人未被选十,若一张选票选中人数大于 5个人时被认为无效的选票。给定函数 ReadDat()的功能是把选票数据读入到字符串数组 xx中。请编制函数 CoutRs()来统计每个人的选票数并把得票数依次 存入 yy0到 yy9中,最后调用函数 WriteDat()把结果

2、yy输出到文件 OUT84.DAT中。 注意:部分源程序已给出。 请勿改动主函数 main()、读函数 ReadDat()和写函数 WriteDat()的内容。 试题程序: #include stdio.h char xx100 11; int yy10; int ReadDat (void); void WriteDat(void); void CoutRs(void) void main() int i; for(i=0;i 10;i+) yyi =0; if (ReadDat () printf (“数据文件 IN84 .DAT不能打开 ! n007“); return; CoutRs

3、); WriteDat (); int ReadDat (void) FILE *fp; int i; char tt13; if ( (fp=fopen (“IN84 .DAT“, “r“) ) =NULL) return 1; for (i=0; i lO0; 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=fopen (“OUT84. DAT“, “w“); for (i=0; i 1

4、0; i+) fprintf (fp, “%dn“, yy i ); printf (“第 %d个人的选票数 =%dn“, i+1, yy i ); fclose (fp); 国家三级(网络技术)机试模拟试卷 84答案与解析 一、程序设计题 1 【正确答案】 void CoutRs (void) int i, count, j; char *pf; for (i=0; i l0;i+) yyi=0; for (i=0; i l00; i+) pf=xx i; /*指针 pf指向字符串的第一个字符 */ count=0; while (*pf) if (*pf=1) count+; /*统计每条

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

展开阅读全文
相关资源
猜你喜欢
  • ANSI IEEE 1473-2010 Communications Protocol Aboard Passenger Trains《火车客运列车的通信协议标准》.pdf ANSI IEEE 1473-2010 Communications Protocol Aboard Passenger Trains《火车客运列车的通信协议标准》.pdf
  • ANSI IEEE 1474.1-2004 Communications-Based Train Control (CBTC) Performance and Functional Requirements《基于通信的顺序控制(CBTC)性能和功能要求用标准》.pdf ANSI IEEE 1474.1-2004 Communications-Based Train Control (CBTC) Performance and Functional Requirements《基于通信的顺序控制(CBTC)性能和功能要求用标准》.pdf
  • ANSI IEEE 1474.2-2003 User Interface Requirements in Communications-Based Train Control (CBTC) Systems《基于通信的训练控制(CBTC)系统中用户接口要求用标准》.pdf ANSI IEEE 1474.2-2003 User Interface Requirements in Communications-Based Train Control (CBTC) Systems《基于通信的训练控制(CBTC)系统中用户接口要求用标准》.pdf
  • ANSI IEEE 1475-2012 The Functioning of Interfaces Among Propulsion Friction Brake and Train-Borne Master Control on Rail Rapid Transit Vehicles《推动装置、摩擦闸和铁路快速运输车辆的火车上主控装置之间的接口功能》.pdf ANSI IEEE 1475-2012 The Functioning of Interfaces Among Propulsion Friction Brake and Train-Borne Master Control on Rail Rapid Transit Vehicles《推动装置、摩擦闸和铁路快速运输车辆的火车上主控装置之间的接口功能》.pdf
  • ANSI IEEE 1477-1998 Standard for Passenger Information System for Rail Transit Vehicles.pdf ANSI IEEE 1477-1998 Standard for Passenger Information System for Rail Transit Vehicles.pdf
  • ANSI IEEE 1484.1-2003 IEEE Standard for Learning TechnologyLearning Technology Systems Architecture (LTSA) (IEEE Computer Society)《学习技术标准.学习技术系统体系结构(LTSA)》.pdf ANSI IEEE 1484.1-2003 IEEE Standard for Learning TechnologyLearning Technology Systems Architecture (LTSA) (IEEE Computer Society)《学习技术标准.学习技术系统体系结构(LTSA)》.pdf
  • ANSI IEEE 1484.11.1-2004 Learning Technology Data Model for Content Object Communication (IEEE Computer Society Incorporating Errata June 24 2010)《学习技术标准.内容目标通信用数据模型》.pdf ANSI IEEE 1484.11.1-2004 Learning Technology Data Model for Content Object Communication (IEEE Computer Society Incorporating Errata June 24 2010)《学习技术标准.内容目标通信用数据模型》.pdf
  • ANSI IEEE 1484.11.2-2003 Learning Technology ECMAScript Application Programming Interface for Content to Runtime Services Communication (IEEE Computer Society)《学习技术标准.运行时服务通信内容用ECM.pdf ANSI IEEE 1484.11.2-2003 Learning Technology ECMAScript Application Programming Interface for Content to Runtime Services Communication (IEEE Computer Society)《学习技术标准.运行时服务通信内容用ECM.pdf
  • ANSI IEEE 1484.11.3-2005 Learning TechnologyExtensible Markup Language (XML) Schema Binding for Data Model for Content Object Communication (IEEE Computer Society)《内容对象通信用数据模型的学习技术.pdf ANSI IEEE 1484.11.3-2005 Learning TechnologyExtensible Markup Language (XML) Schema Binding for Data Model for Content Object Communication (IEEE Computer Society)《内容对象通信用数据模型的学习技术.pdf
  • 相关搜索

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

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