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

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

1、三级网络技术机试-273 及答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.已知在文件 IN13.DAT中存有若干个(个数#includeconio.h#define MAXNUM 200int xx MAXNUM;int totNum = 0; /* 文件 IN13.DAT 中共有多少个正整数 */int totCnt = 0; /* 符合条件的正整的个数 */double totPjz = 0.0; /* 平均值 */int ReadDat (void);void Writedat(void);void CalValue(void)mai

2、n ( )int i;clrscr ();for(i = 0; iMAXNUM; i+)xxi = 0;if (ReadDat ()printf (“数据文件 IN13.DAT 不能打开! /007/n“);return;CalValue ();printf(“文件 IN1B.DAT 中共有正整数= %d 个/n“, totNum);printf(“符合条件的正整数的个数= %d 个/n“, totCnt);printf(“平均值=%.21f/n“, totPjz)Writedat ();int ReadDat (void)FILE *fp;int i = 0;if(fp = fopen (“

3、IN13.DAT“, “r“) = NULL)return 1;while(! feof(fp)fscanf(fp, “%d,“, fclose(fp);return 0;void WriteDat(void)FILE *fp;fp = fopen(“OUT13.DAT“, “w“);fprintf(fp, “%d/n%d/n%.21f/n“, totNum, totCnt, totPjz);fclose (fp);(分数:100.00)_三级网络技术机试-273 答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.已知在文件 IN13.DAT中

4、存有若干个(个数#includeconio.h#define MAXNUM 200int xx MAXNUM;int totNum = 0; /* 文件 IN13.DAT 中共有多少个正整数 */int totCnt = 0; /* 符合条件的正整的个数 */double totPjz = 0.0; /* 平均值 */int ReadDat (void);void Writedat(void);void CalValue(void)main ( )int i;clrscr ();for(i = 0; iMAXNUM; i+)xxi = 0;if (ReadDat ()printf (“数据文件

5、 IN13.DAT 不能打开! /007/n“);return;CalValue ();printf(“文件 IN1B.DAT 中共有正整数= %d 个/n“, totNum);printf(“符合条件的正整数的个数= %d 个/n“, totCnt);printf(“平均值=%.21f/n“, totPjz)Writedat ();int ReadDat (void)FILE *fp;int i = 0;if(fp = fopen (“IN13.DAT“, “r“) = NULL)return 1;while(! feof(fp)fscanf(fp, “%d,“, fclose(fp);re

6、turn 0;void WriteDat(void)FILE *fp;fp = fopen(“OUT13.DAT“, “w“);fprintf(fp, “%d/n%d/n%.21f/n“, totNum, totCnt, totPjz);fclose (fp);(分数:100.00)_正确答案:(void CalValue(void)int i, data;for (i=0; iMAXNUM; i+)if(!xxi)continue; /*如果当前数为 0, 则结束本次循环,取下一个数*/if (xx i 0)totNum+; /*统计正整数的个数*/data=xx i 1; /*将数右移一位

7、/if (data% 2=0) /*如果右移 1位后,产生的新数是偶数*/totCnt+;totPj z+=xx i; /*统计这些数的个数,并将满足条件的原数求和*/totPjz/=totCnt; /*求满足条件的这些数(右移前的值)的算术平均值*/)解析:解析 本题的解题思路是首先利用一个 for循环来依次从数组中取得各数,由于题目要求数组中正整数的个数,因此,零不做任何处理,接着去取下一个数。只要某数大于零,则该数一定是正整数,这时就给变量 totNum(正整数的个数)累加 1,之后把该正整数右移一位后的结果临时保存在变量 data中,再对这个临时变量进行是否偶数的判断。如果该临时变量中保存的值是偶数,则表明原数符合条件,就给变量 totCnt(符合判断条件的正整数个数)累加 1,并把当前的变量 data右移前的原数的值累加到变量totPjz中,当所有符合判断条件的数都被找出后,再对 totPjz进行求平均值的计算。

展开阅读全文
相关资源
猜你喜欢
  • SIS SS-ISO 9314-2-1989 Information processing systems  Fibre Distributed Data Interface (FDDI)  Part 2 Token Ring Media Access Control (MAC)《信息处理系统 光纤分布式数据接口(FDDI) 第2部分:令牌环网介质访问控制(.pdf SIS SS-ISO 9314-2-1989 Information processing systems Fibre Distributed Data Interface (FDDI) Part 2 Token Ring Media Access Control (MAC)《信息处理系统 光纤分布式数据接口(FDDI) 第2部分:令牌环网介质访问控制(.pdf
  • SIS SS-ISO 9314-3-1991 Information processing systems  Fibre Distributed Data Interface (FDDI)  Part 3 Physical Layer Medium Dependent (PMD)《信息处理系统 光纤分布式数据接口(FDDI) 第3部分:物理层中间依靠(PMD.pdf SIS SS-ISO 9314-3-1991 Information processing systems Fibre Distributed Data Interface (FDDI) Part 3 Physical Layer Medium Dependent (PMD)《信息处理系统 光纤分布式数据接口(FDDI) 第3部分:物理层中间依靠(PMD.pdf
  • SIS SS-ISO 9315-1989 Information processing systems Interface between flexible disk cartridge drives and their host controllers《信息处理系统 可折叠磁盘盒驱动器和其主机控制器之间的接口》.pdf SIS SS-ISO 9315-1989 Information processing systems Interface between flexible disk cartridge drives and their host controllers《信息处理系统 可折叠磁盘盒驱动器和其主机控制器之间的接口》.pdf
  • SIS SS-ISO 9316-1989 Information processing systems  Small Computer System Interface (SCSI)《信息处理系统 小型计算机系统接口》.pdf SIS SS-ISO 9316-1989 Information processing systems Small Computer System Interface (SCSI)《信息处理系统 小型计算机系统接口》.pdf
  • SIS SS-ISO 9318-2-1991 Information technology  Intelligent Peripheral Interface  Part 2 Device specific command set for magnetic disk drives《信息技术智能外围接口 第2部分:磁盘驱动器用设备特定指令集》.pdf SIS SS-ISO 9318-2-1991 Information technology Intelligent Peripheral Interface Part 2 Device specific command set for magnetic disk drives《信息技术智能外围接口 第2部分:磁盘驱动器用设备特定指令集》.pdf
  • SIS SS-ISO 9318-3-1991 Information technology  Intelligent Peripheral Interface  Part 3 Device generic command set for magnetic and optical disk drives《信息技术智能外围接口 第3部分:磁盘和光盘驱动器用设备生.pdf SIS SS-ISO 9318-3-1991 Information technology Intelligent Peripheral Interface Part 3 Device generic command set for magnetic and optical disk drives《信息技术智能外围接口 第3部分:磁盘和光盘驱动器用设备生.pdf
  • SIS SS-ISO 9318-4-1991 Information technology  Intelligent Peripheral Interface  Part 4 Device generic command set for magnetic tape drives《信息技术智能外围接口 第4部分:磁带驱动器用设备生成指令集》.pdf SIS SS-ISO 9318-4-1991 Information technology Intelligent Peripheral Interface Part 4 Device generic command set for magnetic tape drives《信息技术智能外围接口 第4部分:磁带驱动器用设备生成指令集》.pdf
  • SIS SS-ISO 9361-1-1992 Indexable inserts for cutting tools  Ceramic inserts with rounded corners  Part 1 Dimensions of inserts without fixing hole《可转位切割刀具 可转位陶瓷刀片 第1部分:无孔刀片尺寸》.pdf SIS SS-ISO 9361-1-1992 Indexable inserts for cutting tools Ceramic inserts with rounded corners Part 1 Dimensions of inserts without fixing hole《可转位切割刀具 可转位陶瓷刀片 第1部分:无孔刀片尺寸》.pdf
  • SIS SS-ISO 9361-2-1992 Indexable inserts for cutting tools  Ceramic inserts with rounded corners  Part 2 Dimensions of inserts with cylindrical fixing hole《可转位切割刀具 可转位陶瓷刀片 第2部分:带固定.pdf SIS SS-ISO 9361-2-1992 Indexable inserts for cutting tools Ceramic inserts with rounded corners Part 2 Dimensions of inserts with cylindrical fixing hole《可转位切割刀具 可转位陶瓷刀片 第2部分:带固定.pdf
  • 相关搜索

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

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