[计算机类试卷]计算机三级网络技术机试(上机操作)模拟试卷19及答案与解析.doc

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

1、计算机三级网络技术机试(上机操作)模拟试卷 19及答案与解析 一、程序设计题 1 函数 ReadData()实现从文件 IN DAT中读取 1000个十进制整数到数组 XX中;请编制函数 Compute(),分别计算出 XX中奇数的个数 odd、偶数的个数 even、平均值 aver以及方差 totfc的值,最后调用函数 WriteData()把结果输出到 OUT DAT文件中。计算方差的公式如下: 原始数据文件存放的格式是:每行存放 10个数。并用逗号隔开。 (每个数均大于 0且小于等于 2000) 注意:部分源程序已给出如下: 清 勿改动主函数 main()和输出数据函数 WriteDat

2、a()的内容。 试题程序: #include #include #include #define MAX 1000 int xxMAX,odd=0, even=0; double aver=0 0, totfc=0 0; void WriteData(void); int Readl)ata(void) int i; FILE*fp; if(fp=fopen(“IN DAT”, “r”)=NULL)re turn 1; for(i=0; i 计 算机三级网络技术机试(上机操作)模拟试卷 19答案与解析 一、程序设计题 1 【正确答案】 Void Compute(Void) int i; for

3、i=0; iMAX; i+) if(xxi 2)测试结点 i是否是奇数 odd+; 累加变量 odd记录奇数数的个数 else如果结点 i不是奇数 even+; 累加变量 even记录偶数数的个数 aver+=xxi;将 xxi累加存入 aver中 aver =MAX; 计算平均数 for(i=0; iMAX; i+) totfc+=(xxi-aver)*(xxi-aver); totfc =MAX; 【试题解析】 本题考查文件的操作、奇偶判断和数学公式的计算。函数ReadData的作用是从文件中读取数据存入数组 xx中,因为数据存放入文件的格式是每个数据被逗号隔开,所以 fscanf(fp, “ d, ”, xxi)语句中字符串 “d, ”中要加入逗号。函数 Compute的作用是计算方差思路是首先顺序读取数组 xx中的结点,若是奇数 (xxi 2, xxi为奇数余数为 1条件表达式为真 ), odd加 1,若不是奇数 (即为偶数 ), even加 1。然后计算平均数,利用循环结构依次读取数组xx,计算方差 totfc。

展开阅读全文
相关资源
猜你喜欢
  • ANSI AWS B2.1-1 8-014-2002 Standard Welding Procedure Specification (SWPS) for Shielded Metal Arc Welding of Carbon Steel to Austenitic Stainless Steel (M-1 to M-8 P-8 S-8 Group 1).pdf ANSI AWS B2.1-1 8-014-2002 Standard Welding Procedure Specification (SWPS) for Shielded Metal Arc Welding of Carbon Steel to Austenitic Stainless Steel (M-1 to M-8 P-8 S-8 Group 1).pdf
  • ANSI AWS B2.1-1 8-227-2002 Standard Welding Procedure Specification (SWPS) for Gas Tungsten Arc Welding of Carbon Steel (M-1 P-1 S-1 Groups 1 or 2) to Austenitic Stainless Steel (M.pdf ANSI AWS B2.1-1 8-227-2002 Standard Welding Procedure Specification (SWPS) for Gas Tungsten Arc Welding of Carbon Steel (M-1 P-1 S-1 Groups 1 or 2) to Austenitic Stainless Steel (M.pdf
  • ANSI AWS B2.1-1 8-228-2002 Standard Welding Procedure Specification (SWPS) for Shielded Metal Arc Welding of Carbon Steel (M-1 P-1 S-1 Groups 1 or 2) to Austenitic Stainless Steel .pdf ANSI AWS B2.1-1 8-228-2002 Standard Welding Procedure Specification (SWPS) for Shielded Metal Arc Welding of Carbon Steel (M-1 P-1 S-1 Groups 1 or 2) to Austenitic Stainless Steel .pdf
  • ANSI AWS B2.1-1 8-229-2002 Standard Welding Procedure Specification (SWPS) for Gas Tungsten Arc Welding followed by Shielded Metal Arc Welding of Carbon Steel (M-1 P-1 S-1 Groups 1.pdf ANSI AWS B2.1-1 8-229-2002 Standard Welding Procedure Specification (SWPS) for Gas Tungsten Arc Welding followed by Shielded Metal Arc Welding of Carbon Steel (M-1 P-1 S-1 Groups 1.pdf
  • ANSI AWS B2.1-1 8-230-2002 Standard Welding Procedure Specification (SWPS) for Gas Tungsten Arc Welding with Consumable Insert Root of Carbon Steel (M-1 P-1 S-1 Groups 1 or 2) to A.pdf ANSI AWS B2.1-1 8-230-2002 Standard Welding Procedure Specification (SWPS) for Gas Tungsten Arc Welding with Consumable Insert Root of Carbon Steel (M-1 P-1 S-1 Groups 1 or 2) to A.pdf
  • ANSI AWS B2.1-1 8-231-2015 Standard Welding Procedure Specification (SWPS) for Gas Tungsten Arc Welding with Consumable Insert Root followed by Shielded Metal Arc Welding of Carbon.pdf ANSI AWS B2.1-1 8-231-2015 Standard Welding Procedure Specification (SWPS) for Gas Tungsten Arc Welding with Consumable Insert Root followed by Shielded Metal Arc Welding of Carbon.pdf
  • ANSI AWS B2.1-1-001-1990 Standard Welding Procedure Specification (WPS) for Shielded Metal Arc Welding of Carbon Steel (M-1 P-1 Group 1 or 2) 3 16 through 3 4 inch in the As-Welded.pdf ANSI AWS B2.1-1-001-1990 Standard Welding Procedure Specification (WPS) for Shielded Metal Arc Welding of Carbon Steel (M-1 P-1 Group 1 or 2) 3 16 through 3 4 inch in the As-Welded.pdf
  • ANSI AWS B2.1-1-002-1990 Standard Welding Procedure Specification (WPS) for Shielded Metal Arc Welding of Carbon Steel (M-1 P-1 Group 1 or 2) 3 16 through 7 8 inch in the As-Welded.pdf ANSI AWS B2.1-1-002-1990 Standard Welding Procedure Specification (WPS) for Shielded Metal Arc Welding of Carbon Steel (M-1 P-1 Group 1 or 2) 3 16 through 7 8 inch in the As-Welded.pdf
  • ANSI AWS B2.1-1-003-2002 Standard Welding Procedure Specification (SWPS) for Gas Metal Arc Welding of Galvanized Steel (M-1) 18 Through 10 Gauage in the As-Welded Condition with or.pdf ANSI AWS B2.1-1-003-2002 Standard Welding Procedure Specification (SWPS) for Gas Metal Arc Welding of Galvanized Steel (M-1) 18 Through 10 Gauage in the As-Welded Condition with or.pdf
  • 相关搜索

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

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