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

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

1、国家三级(网络技术)机试模拟试卷 13及答案与解析 一、程序设计题 1 已知在文件 IN13.DAT中存有若干个 (个数 #include conio.h #define MAXNUM 200 int 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; clr

2、scr (); for(i = 0; i MAXNUM; i+) xxi = 0; if (ReadDat () printf (“数据文件 IN13.DAT 不能打开 ! 007n“); return; CalValue (); printf(“文件 IN1B.DAT 中共有正整数 = %d 个 n“, totNum); printf(“符合条件的正整数的个数 = %d 个 n“, totCnt); printf(“平均值 =%.21fn“, 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, “%dn%dn%.21fn“, totNum, totCnt, totPjz); fclose (fp); 国家三级(网络技术)机试模拟试卷 13答案与解析 一、程序设计题 1 【正确答案】 void CalValue(void) int i, data; for (i

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

展开阅读全文
相关资源
猜你喜欢
  • ANSI AIIM MS54-1993 Graphic Symbols for Controls on Document Imaging Equipment《文档成像设备上控制装置的图形符号》.pdf ANSI AIIM MS54-1993 Graphic Symbols for Controls on Document Imaging Equipment《文档成像设备上控制装置的图形符号》.pdf
  • ANSI AIIM MS55-1994 Standard Recommended Practice for the Identification and Indexing of Page Components (Zones) for Automated Processing in an Electronic Image Management (EIM) En.pdf ANSI AIIM MS55-1994 Standard Recommended Practice for the Identification and Indexing of Page Components (Zones) for Automated Processing in an Electronic Image Management (EIM) En.pdf
  • ANSI AIIM MS58-1996 Standard Recommended Practice for Implementation of Small Computer Systems Interface (SCSI-2) (X3.131-1994) for Scanners《扫描器用的小型计算机系统接口(SCSI-2)应用的标准推荐实施规程》.pdf ANSI AIIM MS58-1996 Standard Recommended Practice for Implementation of Small Computer Systems Interface (SCSI-2) (X3.131-1994) for Scanners《扫描器用的小型计算机系统接口(SCSI-2)应用的标准推荐实施规程》.pdf
  • ANSI AIIM MS59-1996 Media Error Monitoring and Reporting Techniques for Verification of Stored Data on Optical Digital Data Disks《在光学数字数据盘上存储信息验证用媒体出错监测和报告技术的标准推荐实施规程》.pdf ANSI AIIM MS59-1996 Media Error Monitoring and Reporting Techniques for Verification of Stored Data on Optical Digital Data Disks《在光学数字数据盘上存储信息验证用媒体出错监测和报告技术的标准推荐实施规程》.pdf
  • ANSI AIIM MS6-1993 Microfilm Packaging Labeling《缩微胶片包装标签》.pdf ANSI AIIM MS6-1993 Microfilm Packaging Labeling《缩微胶片包装标签》.pdf
  • ANSI AIIM MS60-1996 Standard - Electronic Folder Interchange Datastream《信息和图像管理.标准.电子文件夹交换数据流》.pdf ANSI AIIM MS60-1996 Standard - Electronic Folder Interchange Datastream《信息和图像管理.标准.电子文件夹交换数据流》.pdf
  • ANSI AIIM MS61-1996 Standard - Application Programming Interface (API) for Scanners in Document Imaging Systems《文档成像系统中扫描器的应用编程接口(API)》.pdf ANSI AIIM MS61-1996 Standard - Application Programming Interface (API) for Scanners in Document Imaging Systems《文档成像系统中扫描器的应用编程接口(API)》.pdf
  • ANSI AIIM MS62-1999 Recommended Practice for COM Recording Systems Having an Internal Electronic Forms Generating System - Operational Practices for Inspection and Quality Control《.pdf ANSI AIIM MS62-1999 Recommended Practice for COM Recording Systems Having an Internal Electronic Forms Generating System - Operational Practices for Inspection and Quality Control《.pdf
  • ANSI AIIM MS66-1999 Metadata for Interchange of Files on Sequential Storage Media Between File Storage Management Systems (FSMSs)《文件储存管理系统(FSMS)间系列存储介质文件互换用元数据》.pdf ANSI AIIM MS66-1999 Metadata for Interchange of Files on Sequential Storage Media Between File Storage Management Systems (FSMSs)《文件储存管理系统(FSMS)间系列存储介质文件互换用元数据》.pdf
  • 相关搜索

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

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