【计算机类职业资格】三级网络技术机试-34及答案解析.doc

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

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

2、yy9中,最后调用函数 WriteDat()把结果 yy 输出到文件 OUT50.DAT 中。请勿改动主函数 main()、读函数 ReadDat()和写函数 WriteDat()的内容。试题程序:#includestdio.hchar xx100 11;int yy10;int ReadDat (void);void WriteDat(void);void CoutRs(void)void main()int i;for(i=0;i10;i+)yyi=0;if (ReadDat ()printf (“数据文件 ENG50. IN 不能打开! /n/007“return;CoutRs ( );

3、WriteDat ();int ReadDat (void)FILE *fp;int i;char tt13;if ( (fp=fopen (“ENG50. IN“, “r“) ) =NULL)return 1;for (i=0; i100; i+)if (fgets (tt, 13, fp) =NULL)return 1;memcpy (xx i , tt, 10);xxi10=0;fclose (fp);return 0;void WriteDat()FILE *fp;int i;fp= fopen (“OUTS0.DAT“, “w“);for (i=0; i10; i+)fprintf

4、fp, “%d/n“, yy i );printf (“第%d 个人的选票数=%d/n“, i+l, yyi );fclose (fp);(分数:100.00)_三级网络技术机试-34 答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.对 10 个候选人进行选举,现有一个 100 条记录的选票文件 ENG50.1N,其数据存放格式是每条记录的长度均为 10 位,第一位表示第一个人的选中情况,第二位表示第二个人的选中情况,依此类推。每一位候选人的记录内容均为字符 0 或 1,1 表示此人被选中,0 表示此人未被选中,全选或全不选(空选票)均为无

5、效的选票。给定函数 ReadDat()的功能是把选票记录读入到字符串数组 xx 中。请编制函数 CoutRs()来统计每个人的选票数并把得票数依次存入 yy0,jyy9中,最后调用函数 WriteDat()把结果 yy 输出到文件 OUT50.DAT 中。请勿改动主函数 main()、读函数 ReadDat()和写函数 WriteDat()的内容。试题程序:#includestdio.hchar xx100 11;int yy10;int ReadDat (void);void WriteDat(void);void CoutRs(void)void main()int i;for(i=0;i

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

7、 WriteDat()FILE *fp;int i;fp= fopen (“OUTS0.DAT“, “w“);for (i=0; i10; i+)fprintf (fp, “%d/n“, yy i );printf (“第%d 个人的选票数=%d/n“, i+l, yyi );fclose (fp);(分数:100.00)_正确答案:(void CoutRs(void)int i,j=0,k=0;char *str;for(i=0;i100;i+)str=xx i; /*指针 str 指向该行首地址*/j=0;while (*str !=0)if (*str=1) /*统计1的个数*/j+;s

8、tr+; /*取下一个字符*/else str+; /*如果该字符不是1,则什么都不做,取下一个字符*/if(j!=0j!=10) /*如果既不是全选也不是空票,则为有效票*/str=xx i; /*指针 str 指向该行首地址*/k=0;while (*str)if *str+= 1) /*将每个人的得票数依次存入 yy 0到 yy9中*/yy k+ +=1;else k+;str+; )解析:解析本题考查的知识点如下:(1)二维数组的操作。(2)指向数组的指针。在本题中,要先判断选票是否有效。因为记录存放在一个二位数组中,为了简便我们为数组的一组元素定义一个指向数组的指针,例如,char*p=xx2。初始时该指针指向该组的第一个元素,指针地址每加 1,则指向下一个元素。这样就可以轻松地统计每一个选票。设一变量标记每一个选票中 1 的个数,若其不为0 和 10,则选票有效。若选票有效,则依次查看哪一个元素为 1,在数组 yy 相应的元素上加 1。使用循环实现对所有记录的访问。

展开阅读全文
相关资源
猜你喜欢
  • CSN 25 4155-1964 Limit ring thread  NOT GO  gauges Whitworth thread Diameter W 1 8  - W 3 《非穿过型规限制环形螺纹 惠氏螺纹 W 1 8 - W3 直径》.pdf CSN 25 4155-1964 Limit ring thread NOT GO gauges Whitworth thread Diameter W 1 8 - W 3 《非穿过型规限制环形螺纹 惠氏螺纹 W 1 8 - W3 直径》.pdf
  • CSN 25 4156-1964 Reference gauges for ring  NOT GO  gauges Whitworth thread Diameter W 1 8  - W 3 《非穿过型环形螺纹校准规 惠氏螺纹 1 S   W 9 直径》.pdf CSN 25 4156-1964 Reference gauges for ring NOT GO gauges Whitworth thread Diameter W 1 8 - W 3 《非穿过型环形螺纹校准规 惠氏螺纹 1 S W 9 直径》.pdf
  • CSN 25 4157-1964 Measuring parts of reference gauges for ring thread  NOT GO  gauges Whitworth thread Diameter W 1 8  - W 3 《非穿过型端螺纹校准量规的测量部件 惠氏螺纹 W 1 8 到W 3 直径》.pdf CSN 25 4157-1964 Measuring parts of reference gauges for ring thread NOT GO gauges Whitworth thread Diameter W 1 8 - W 3 《非穿过型端螺纹校准量规的测量部件 惠氏螺纹 W 1 8 到W 3 直径》.pdf
  • CSN 25 4170-1963 Cylindrical limit thread gauges bothsided Cylindrical pipe thread Diameter G 1 8  - G 7 8 《双边圆柱形极限螺纹规 圆柱形导管螺纹 1 8  - G 7 8 直径》.pdf CSN 25 4170-1963 Cylindrical limit thread gauges bothsided Cylindrical pipe thread Diameter G 1 8 - G 7 8 《双边圆柱形极限螺纹规 圆柱形导管螺纹 1 8 - G 7 8 直径》.pdf
  • CSN 25 4171-1963 Cylindrical thread  GO  gauges Cylindrical pipe thread Diameter G 1  - G 3 1 2 《圆柱型螺纹穿过型量规 圆柱型管螺纹 O 1  3 1 2 直径》.pdf CSN 25 4171-1963 Cylindrical thread GO gauges Cylindrical pipe thread Diameter G 1 - G 3 1 2 《圆柱型螺纹穿过型量规 圆柱型管螺纹 O 1 3 1 2 直径》.pdf
  • CSN 25 4172-1963 Measuring parts of  GO  limit of cylindrical thread gauges Cylindrical pipe thread Diameter G 1 8  - G 3 1 2 《穿过限圆柱形螺纹规的测量部件 圆柱形导管螺纹 直径G 1 8  -G3 1 2》.pdf CSN 25 4172-1963 Measuring parts of GO limit of cylindrical thread gauges Cylindrical pipe thread Diameter G 1 8 - G 3 1 2 《穿过限圆柱形螺纹规的测量部件 圆柱形导管螺纹 直径G 1 8 -G3 1 2》.pdf
  • CSN 25 4173-1963 Cylindrical thread  NOT GO  gauges Cylindrical pipe thread Diameter G 1  - G 3 1 2 《非穿过型规圆柱形螺纹 圆柱形导管螺纹 G 1   3 1 2 直径》.pdf CSN 25 4173-1963 Cylindrical thread NOT GO gauges Cylindrical pipe thread Diameter G 1 - G 3 1 2 《非穿过型规圆柱形螺纹 圆柱形导管螺纹 G 1 3 1 2 直径》.pdf
  • CSN 25 4174-1963 Measuring parts of  NOT GO  limits of cylindrical thread gauges Cylindrical pipe thread Diameter G 1 8  - G 3 1 2 《非穿过型 圆柱型螺纹规限制的测量部件 圆柱形导管螺纹 G 1 8  - O 3 1 2 直径》.pdf CSN 25 4174-1963 Measuring parts of NOT GO limits of cylindrical thread gauges Cylindrical pipe thread Diameter G 1 8 - G 3 1 2 《非穿过型 圆柱型螺纹规限制的测量部件 圆柱形导管螺纹 G 1 8 - O 3 1 2 直径》.pdf
  • CSN 25 4180-1963 Ring limit thread  GO  gauges Cylindrical pipe thread Diameter G 1 8  - G 3 1 2 《穿过型规环形限制螺纹 圆柱型管螺纹 Q 1 8   3 1 2 直径》.pdf CSN 25 4180-1963 Ring limit thread GO gauges Cylindrical pipe thread Diameter G 1 8 - G 3 1 2 《穿过型规环形限制螺纹 圆柱型管螺纹 Q 1 8 3 1 2 直径》.pdf
  • 相关搜索

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

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