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

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

1、三级网络技术机试-74 及答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.请编制函数 ReadDa()实现从文件 IN83.DAT 中读取 1000 个十进制整数到数组 xx 中。请编制函数 Compute()分别计算出 xx 中奇数的个数 odd、奇数的平均值 avel、偶数的平均值 ave2 及所有奇数的方差totfc 的值。最后调用函数 WrireDat()把结果输出到 OUT83.DAT 文件中。计算方差的公式如下:(分数:100.00)_三级网络技术机试-74 答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:

2、1,分数:100.00)1.请编制函数 ReadDa()实现从文件 IN83.DAT 中读取 1000 个十进制整数到数组 xx 中。请编制函数 Compute()分别计算出 xx 中奇数的个数 odd、奇数的平均值 avel、偶数的平均值 ave2 及所有奇数的方差totfc 的值。最后调用函数 WrireDat()把结果输出到 OUT83.DAT 文件中。计算方差的公式如下:(分数:100.00)_正确答案:(int ReadDat(void)FILE *fp;int i,j;if(fp=fopen(“IN83.DAT“,“r“)=NULL) return 1;for(i=0;i100;i

3、) for(j=0;j10;j+)fscanf(fp,“%d,“,fscanf(fp,“/n“);if(feof(fp) break;fclose(fp);return 0;void Compute (void) int i,yyMAX;for(i=0;i1000;i+)if(xxi%2!=0)odd+; /*计算出 xx 中奇数的个数 odd*/ave1+=xxi; /*求奇数的和*/yy odd-l =xx i; /*将奇数存入组中 yy 中*/elseeven+; /*计算出 xx 中偶数的个数 even*/ave2+=xxi; /*求偶数的和*/ave1/=odd; /*求奇数的平均

4、值*/ave2/=even; /*求偶数的平均值*/for(i=0;iodd;i+)totfc+=(yyi-ave1)*(yyi-ave1)/odd; /*求所以奇数的方差*/ )解析:解析 本题考查的知识点如下:(1)从文件中读取数据。(2)奇偶数的判断和方差的求法。在 C 语言中,有一结构体类型 FILE,其中包含文件的一些属性信息。可定义指针指向该结构体,这个指针称为文件指针。要从文件中读取数据,首先要判断该文件是否能以“读”的方式打开。若能打开,使用函数 int fscanf(FILE*fp,char*format,args)从 fp 所指向的文件中依次读取数据。在本题中,数据的存放很有规律,将数据读出存入数组 xx 时,只要控制数组下标就可以了。若文件结束,则退出读取循环。最后要关闭文件。若一个数除以 2 取余得 0,则该数是偶数,否则为奇数。由方差公式可知,这是求一些连续的数的表达式的值,所以可以使用循环求得方差。

展开阅读全文
相关资源
猜你喜欢
  • NBN-EN 28849-1994 8750 Small craft Electrically operated bilge-pumps (ISO 8849 1990)《游艇 电动舱底泵(ISO 8849:1990)》.pdf NBN-EN 28849-1994 8750 Small craft Electrically operated bilge-pumps (ISO 8849 1990)《游艇 电动舱底泵(ISO 8849:1990)》.pdf
  • NBN-EN 28871-1993 1875 Elastomeric parts for aqueous parenteral preparations (ISO 8871 1988)《含水非肠道药配制剂用弹性件(ISO 8871:1988)》.pdf NBN-EN 28871-1993 1875 Elastomeric parts for aqueous parenteral preparations (ISO 8871 1988)《含水非肠道药配制剂用弹性件(ISO 8871:1988)》.pdf
  • NBN-EN 28872-1993 8750 Aluminium caps for transfusion infusion and injection bottles General requirements and test methods (ISO 8872 1988)《输血,输液及注射瓶的铝盖 一般要求和试验方法(ISO 8872:1988)》.pdf NBN-EN 28872-1993 8750 Aluminium caps for transfusion infusion and injection bottles General requirements and test methods (ISO 8872 1988)《输血,输液及注射瓶的铝盖 一般要求和试验方法(ISO 8872:1988)》.pdf
  • NBN-EN 28877-1994 6875 Information technology - Telecommunications and information exchange between systems - Interface connector and contact assignments for ISDN Basic Access InteSO .pdf NBN-EN 28877-1994 6875 Information technology - Telecommunications and information exchange between systems - Interface connector and contact assignments for ISDN Basic Access InteSO .pdf
  • NBN-EN 28891-1992 6875 Dental casting alloys with noble metal content of 25 % up to but not including 75 % (ISO 8891 1990)《贵金属含量至少为25%但低于75%的牙科用铸造合金(ISO 8891:1990)》.pdf NBN-EN 28891-1992 6875 Dental casting alloys with noble metal content of 25 % up to but not including 75 % (ISO 8891 1990)《贵金属含量至少为25%但低于75%的牙科用铸造合金(ISO 8891:1990)》.pdf
  • NBN-EN 289-1994 7500 Rubber and plastics machinery Compression and transfer moulding presses Safety requirements for the design《塑料和橡胶用的压制和输送机设计的技术安全要求》.pdf NBN-EN 289-1994 7500 Rubber and plastics machinery Compression and transfer moulding presses Safety requirements for the design《塑料和橡胶用的压制和输送机设计的技术安全要求》.pdf
  • NBN-EN 28996-1994 4375 Ergonomics Determination of metabolic heat production (ISO 8996 1990)《人类工效学 代谢热量的测定(ISO 8996:1990)》.pdf NBN-EN 28996-1994 4375 Ergonomics Determination of metabolic heat production (ISO 8996 1990)《人类工效学 代谢热量的测定(ISO 8996:1990)》.pdf
  • NBN-EN 29000-1990 6875 Quality management and quality assurance standards - Guidelines for selection and use《质量管理和质量保证 选则和使用导则》.pdf NBN-EN 29000-1990 6875 Quality management and quality assurance standards - Guidelines for selection and use《质量管理和质量保证 选则和使用导则》.pdf
  • NBN-EN 29000-3-1993 1250 Quality management and quality assurance standards Part 3 Guidelines for the application of ISO 9001 to the development supply and maintenance of software .pdf NBN-EN 29000-3-1993 1250 Quality management and quality assurance standards Part 3 Guidelines for the application of ISO 9001 to the development supply and maintenance of software .pdf
  • 相关搜索

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

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