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

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

1、国家三级(网络技术)机试模拟试卷 315及答案与解析 一、程序设计题 1 已知数据文件 in80. dat中存有 300个 4位数,并已调用函数 readDat()把这些数存入数组 a中,请编制一函数 isValue(),其功能是:求出个位数上的数减千位数上的数减百位数上的数减十位数上的数大于 0的个数 cnt,再求出所有满足此条件的4位数平均值 pjz1,以及所有不满足此条件的 4位数平均值 pjz2,最后调用函数 writeDat()把结果 cnt, pjz1, pjz2输出到 out80. dat文件。 例如: 1239, 9-1-2-3 0,则该数满足条件,计算平均值 pjz1,且个数

2、cnt=cnt+1。 8129, 9-8-1-2 0,则该数不满足条件,计算平均值 pjz2。 注意:部分源程序已给出。 程序中已定义数组: a300, b300, 定义变量: cnt, pjz1, pjz2。 请勿改动主函数 main()、读函数 readDat()和写函数 writeDa()的内容。 试题程序: #include stdio.h int a300, cnt=0; double pjzl=0.0,pjz2=0.0; void jsValue() main ( ) int i; readDat(); jsValue(); writeDat(); printf (“cnt=%dn

3、 满足条件的平均值 pjz1=%7.2Ifn 不满足条件的平均值 pjz2=%7.2Ifn“,cnt,pjz1,pjz2); readDat() FILE *fp; int i; fp=fopen “in80.dat“,“r“); for(i=0;i 300;i+) fscanf(fp,“%d,“, fclose(fp); writeDat () FILE *fp; int i; fp=fopen(“out80.dat“,“w“); fprintf(fp,“%dn%7.21fn%7.21fn“,cnt ,pjzl,pjz2); fclose(fp); 国家三级(网络技术)机试模拟试卷 315答

4、案与解析 一、程序设计题 1 【正确答案】 void jsValue() int i, thou, hun, ten, data, n=0; for(i=O;i 300;i+) thou=a i /1000; /*求四位数的千位数字 */ hun=a i %1000/100; /*求四位数的百位数字 */ ten=a i %100/10; /*求四位数的十位数字 */ data=a i %10; /*求四位数的个位数字 */ if (data-thou-hun-ten 0) /*如果个位数减千位数减百位数大于 0*/ cnt+; /*统计满足条件的数的个数 */ pjz1+=a i; /*将满

5、足条件的数求和 */ else n+; /*否则统计不满足条件的数的个数 */ pjz2+=a Ii; /*将不满足条件的数求和 */ pjz1/=cnt; /求满足条件的数的平均值 */ pjz2/=n; /* 求不满足条件的数的平均值 */ 【试题解析】 本题考查的知识点如下: (1)特殊运算符 “%” 及 “/”的使用。 (2)循环结构及选择结构的使用 ? 在本题中,首先要将一个 4位数的千位、百位、十位、个位拆成独立的数字。这里借助特殊运算符号 “%” ( 取余 )和 “/” (整除 ),拆分方法略。然后判断 “个位数 -千位数 -百位数 -十位数 ”的值是否大于 0。依次求得符合条件的数的和及其平均值。

展开阅读全文
相关资源
猜你喜欢
  • AECMA PREN 2738-1986 Aerospace Series Magnesium Alloy Mg-C43-T5 Sand Castings Issue P 1《航空和航天系列镁合金 Mg-C43-T5软铸造》.pdf AECMA PREN 2738-1986 Aerospace Series Magnesium Alloy Mg-C43-T5 Sand Castings Issue P 1《航空和航天系列镁合金 Mg-C43-T5软铸造》.pdf
  • AECMA PREN 2739-1986 Aerospace Series Magnesium Alloy Mg-C43-T5 Chill Castings Issue P 1《航空和航天系列镁合金Mg-C43-T5冷硬铸造》.pdf AECMA PREN 2739-1986 Aerospace Series Magnesium Alloy Mg-C43-T5 Chill Castings Issue P 1《航空和航天系列镁合金Mg-C43-T5冷硬铸造》.pdf
  • AECMA PREN 2742-1986 Aerospace Series Magnesium Alloy Mg-C71-F Sand Castings Issue P 1《航空和航天系列镁合金 Mg-C71-F软铸造》.pdf AECMA PREN 2742-1986 Aerospace Series Magnesium Alloy Mg-C71-F Sand Castings Issue P 1《航空和航天系列镁合金 Mg-C71-F软铸造》.pdf
  • AECMA PREN 2743-1991 Aerospace Series Reinforced Plastics Standard Procedures for Conditioning Prior to Testing Issue P 1《航空和航天系列加固塑料标准程序在测试前情况下》.pdf AECMA PREN 2743-1991 Aerospace Series Reinforced Plastics Standard Procedures for Conditioning Prior to Testing Issue P 1《航空和航天系列加固塑料标准程序在测试前情况下》.pdf
  • AECMA PREN 2744-1990 Aerospace Series Non-Metallic Materials Preferred Test Temperatures Edition 1《航空和航天系列非金属物质首选温度》.pdf AECMA PREN 2744-1990 Aerospace Series Non-Metallic Materials Preferred Test Temperatures Edition 1《航空和航天系列非金属物质首选温度》.pdf
  • AECMA PREN 2746-1990 Aerospace Series Glass Fibre Reinforced Plastics Determination of Flexural Properties Three Point Bend Method Issue P 1《航空和航天系列玻璃纤维加固塑料曲折度测试 三点弯曲方法P.第1版》.pdf AECMA PREN 2746-1990 Aerospace Series Glass Fibre Reinforced Plastics Determination of Flexural Properties Three Point Bend Method Issue P 1《航空和航天系列玻璃纤维加固塑料曲折度测试 三点弯曲方法P.第1版》.pdf
  • AECMA PREN 2747-1990 Aerospace Series Glass Fibre Reinforced Plastics Determination of Tensile Properties Issue P 1《航空和航天系列玻璃纤维加固塑料可拉伸长度测试》.pdf AECMA PREN 2747-1990 Aerospace Series Glass Fibre Reinforced Plastics Determination of Tensile Properties Issue P 1《航空和航天系列玻璃纤维加固塑料可拉伸长度测试》.pdf
  • AECMA PREN 2751-1996 Aerospace Series Storage Conditions for Rubber Products Requirements for Storage Cleaning and Maintenance《航空和航天系列橡胶制品储藏 清洗和维持条件》.pdf AECMA PREN 2751-1996 Aerospace Series Storage Conditions for Rubber Products Requirements for Storage Cleaning and Maintenance《航空和航天系列橡胶制品储藏 清洗和维持条件》.pdf
  • AECMA PREN 2752-1986 Aerospace Series Nuts Anchor Self Locking Fixed Two Lug Reduced Series with Counterbore Classification 1100 MPa 235 Degrees Celsius Edition 1《航空和航天系列自锁固定双接片带扩孔.pdf AECMA PREN 2752-1986 Aerospace Series Nuts Anchor Self Locking Fixed Two Lug Reduced Series with Counterbore Classification 1100 MPa 235 Degrees Celsius Edition 1《航空和航天系列自锁固定双接片带扩孔.pdf
  • 相关搜索

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

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