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

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

1、国家三级(网络技术)机试模拟试卷 284及答案与解析 一、程序设计题 1 文件 IN DAT中存有 300个四位整型数,函数 ReadData()负责将 IN DAT中的数读到数组 inBuf中。请编写函数 findvalue(),其功能是;求出千位数上的数加百位数上的数等于十位数上的数加个位数上的数的个数 count,再求出所有满足此条件的四位数平均值 average1,以及所有不满足此条件的四位数平均值 average2,最后调用函数 WriteData()把结果 count、 aVeragel、 aVeragez2输出 到 OUT.DAT文件中。 程序中已定义数组; inBuf300,已

2、定义变量; count, averagel, average2。 请勿改动主函数 main()、读函数 ReadData()和写函数 WriteData()的内容。 #include #define NUM 300 int inBufNUM, count=0; double averagel=0, average2=0; void ReadData(); void WriteData(); void findValue() void main() ReadData(); findValue(); WriteData(); printf(“count= d naveragl= 7 21f nav

3、erag2= 7 21f n“, count,averagel, average2); void ReadData() FILE*fp; int i; fp=fopen(“IN DAT“, “r“); for(i=0; iNUM; i+) fscanf(fp, “ d, “, &inBufi); fclose(fp); void writeData() FILE*fp; fp=fopen(“OUT DAT“, “w“); fprintf(fp, “count= dnaveragl= 7 2lf naverag2= 7 21f n“, count,averagel, average2); fcl

4、ose(fp); 国家三级(网络技术)机试模拟试卷 284答案与解析 一、程序设计题 1 【正确答案】 void findValue() int i, j, k, d4, temp, count_no=0; for(i=0; iNUM; i+) for(j=0; j4; j+) temp=inBufi; 将要进行分解的数据存入 temp中 for(k=0; kj; k+)temp=temp 10; 求第 j位的值 d3-j=temp 10; 先将 temp除以 10的 j次方,再对其求余即可 if(d0+d1=d2+d3) count+; 符合条件项的计数器加 1, averagel*(cou

5、nt-1)得到前 count-1个数的总和 averagel=(averagel*(count-1)+(double)inBufi) count; else count_no+; 不符合条件项的计数器加 1 average2=(average2*(count_no-1)+(double)inBufi) count_no; 【试题解析】 本题主要考查数位分解及数据平均值的求法。程序步骤; 1将数值送入 temp中。 2数位分解;由 temp 1 0得到个位数; (temp 10) 10得到十位数 如此可得到各数位上的数值。 3按照题目所给的条件选出数据。4对选出的数据求平均值;由于本题中的数据量比较大,若采用先将各个值加起来再除以总个数来取平均的话,变量不能存储那么大的数据而导致溢出。本题的程序采用的方法是; N个数的平均值 =前 (N-1)个数的平均值 *(N-1)+第 N个数 N,采用这种递推的方法就避 免了将大的数据存入变量中而产生溢出。

展开阅读全文
相关资源
猜你喜欢
  • ANSI ISO IEC 10746-3-1996 Information technology - Open Distributed Processing - Reference Model Architecture (Adopted by INCITS)《信息技术.开放式分布加工.参考模型 被INCITS采用的架构》.pdf ANSI ISO IEC 10746-3-1996 Information technology - Open Distributed Processing - Reference Model Architecture (Adopted by INCITS)《信息技术.开放式分布加工.参考模型 被INCITS采用的架构》.pdf
  • ANSI ISO IEC 10918-2-1995 Information technology - Digital compression and coding of continuous-tone still images Compliance testing Adopted by INCITS《信息技术.数字压缩和连续调次静止图象的编码 采用INCIT.pdf ANSI ISO IEC 10918-2-1995 Information technology - Digital compression and coding of continuous-tone still images Compliance testing Adopted by INCITS《信息技术.数字压缩和连续调次静止图象的编码 采用INCIT.pdf
  • ANSI ISO IEC 10994-1992 Information technology - Data interchange on 90 mm flexible disk cartridges using modified frequency modulation recording at 31 831 ftprad on 80 tracks on e.pdf ANSI ISO IEC 10994-1992 Information technology - Data interchange on 90 mm flexible disk cartridges using modified frequency modulation recording at 31 831 ftprad on 80 tracks on e.pdf
  • ANSI ISO IEC 11160-1-1996 Information technology - Office equipment - Minimum information to be included in specification sheets - Printers - Part 1 Class 1 and Class 2 printers (A.pdf ANSI ISO IEC 11160-1-1996 Information technology - Office equipment - Minimum information to be included in specification sheets - Printers - Part 1 Class 1 and Class 2 printers (A.pdf
  • ANSI ISO IEC 11160-2-1996 Information technology - Office equipment - Minimum information to be included in specification sheets - Printers - Part 2 Class 3 and Class 4 printers (A.pdf ANSI ISO IEC 11160-2-1996 Information technology - Office equipment - Minimum information to be included in specification sheets - Printers - Part 2 Class 3 and Class 4 printers (A.pdf
  • ANSI ISO IEC 11557-1992 for Information Technology 3.81 mm Wide Magnetic Tape Cartridge for Information Interchange Helical Scan Recording DDS-DC Format Using 60 m and 90 m Length .pdf ANSI ISO IEC 11557-1992 for Information Technology 3.81 mm Wide Magnetic Tape Cartridge for Information Interchange Helical Scan Recording DDS-DC Format Using 60 m and 90 m Length .pdf
  • ANSI ISO IEC 11572-1997 for Information Technology – Telecommunications and Information Exchange Between Systems – Private Integrated Services Network – Circuit Mode Bearer Servicrot.pdf ANSI ISO IEC 11572-1997 for Information Technology – Telecommunications and Information Exchange Between Systems – Private Integrated Services Network – Circuit Mode Bearer Servicrot.pdf
  • ANSI ISO IEC 11574-1994 for Information Technology Telecommunications and Information Exchange Between Systems Private Integrated Services Network Circuit-mode 64 kbit s Bearer Sers.pdf ANSI ISO IEC 11574-1994 for Information Technology Telecommunications and Information Exchange Between Systems Private Integrated Services Network Circuit-mode 64 kbit s Bearer Sers.pdf
  • ANSI ISO IEC 11576-1994 Information technology - Procedure for the registration of algorithms for the lossless compression of data《信息技术.INCITS采纳的用于数据无损耗压缩的算法注册规程》.pdf ANSI ISO IEC 11576-1994 Information technology - Procedure for the registration of algorithms for the lossless compression of data《信息技术.INCITS采纳的用于数据无损耗压缩的算法注册规程》.pdf
  • 相关搜索

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

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