[计算机类试卷]国家三级信息管理技术机试模拟试卷118及答案与解析.doc

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

1、国家三级信息管理技术机试模拟试卷 118及答案与解析 一、程序设计题 1 已知数据文件 IN14.DAT中存有 300个四位数,并已调用读函数 readDat()把这些数存入数组 a中。请编制一个函数 jsValue(),其功能是:求出所有这些四位数是素数的个数 cnt,再把所有满足此条件的四位数依次存入数组 b中,然后对数组 b中的四位数按从小到大的顺序进行排序,最后调用写函数 writeDat()把结果输出到OUT14.DAT文件。 例如: 5591是素数,则该数满足条件存入数组 b中,且个数 cnt=cnt+1。 9812是非素数,则该数不满足条件,忽略。 注意:部分源程序已给出。程序中

2、已定义数组: a300、 b300;已定义变量:cnt。请勿改动主函数 main()、读函数 readDat()和写函数 writeDat()的内容。 试题程序 #include stdio.h int a300,b300,cnt=0; int isP(int m) int i; for(i=2;i m;i+) if(m%i=0)return 0; return 1; void jsValue() main() int i; readDat(); jsValue(); writeDat(); for(i=0;i cnt;i+)printf(“b%d=%d n“,i,bi); readDat()

3、 FILE *fp; int i; fp=fopen(“IN14.DAT“,“r“); for(i=0;i 300;i+)fscanf(fp,“%d,“,i cnt;i+)fprintf(fp,“%d n“,bi); fclose(fp); 国家三级信息管理技术机试模拟试卷 118答案与解析 一、程序设计题 1 【正确答案】 void jsValue() int j,i,value; for(i=0;i 300;i+) if(isP(ai)bcnt=ai;cnt+; for(i=0;i cnt-1;i+) /*将数组 b中的四位数按从小到大的顺序进行排序 */ for(j=i+1;j cnt;j+) if(bi bi)value=bi;bi=bj;bj=value; 解析 此题型考查的知识点包括以下几方面: (1) 运算符 “/”(相除 )和 “%”(取余 )的灵活运用; (2) 循环结构的使用; (3) 数据的排序 (在这里主要是使用选择排序法 ); (4) 选择结构的使用。 此函数的功能是:求出所有这些四位数中是素数的数值,并依次存入数组 b中,然后对数组 b中的四位数按从小到大的顺序进行排序。程序中判断素数的函数 isP()已 给出。

展开阅读全文
相关资源
猜你喜欢
  • ASTM A844 A844M-2009(2015) Standard Specification for Steel Plates 9&x2009 %&x2009 Nickel Alloy for Pressure Vessels Produced by the Direct-Quenching Process《使用直接淬火工艺生产的压力容器的9%镍合金钢.pdf ASTM A844 A844M-2009(2015) Standard Specification for Steel Plates 9&x2009 %&x2009 Nickel Alloy for Pressure Vessels Produced by the Direct-Quenching Process《使用直接淬火工艺生产的压力容器的9%镍合金钢.pdf
  • ASTM A847 A847M-2005 Standard Specification for Cold-Formed Welded and Seamless High-Strength Low-Alloy Structural Tubing with Improved Atmospheric Corrosion Resistance《具有增强耐大气腐蚀性能.pdf ASTM A847 A847M-2005 Standard Specification for Cold-Formed Welded and Seamless High-Strength Low-Alloy Structural Tubing with Improved Atmospheric Corrosion Resistance《具有增强耐大气腐蚀性能.pdf
  • ASTM A847 A847M-2011 Standard Specification for Cold-Formed Welded and Seamless High-Strength Low-Alloy Structural Tubing with Improved Atmospheric Corrosion Resistance《具有增强耐大气腐蚀性能.pdf ASTM A847 A847M-2011 Standard Specification for Cold-Formed Welded and Seamless High-Strength Low-Alloy Structural Tubing with Improved Atmospheric Corrosion Resistance《具有增强耐大气腐蚀性能.pdf
  • ASTM A847 A847M-2012 Standard Specification for Cold-Formed Welded and Seamless High-Strength Low-Alloy Structural Tubing with Improved Atmospheric Corrosion Resistance《具有增强耐大气腐蚀性能.pdf ASTM A847 A847M-2012 Standard Specification for Cold-Formed Welded and Seamless High-Strength Low-Alloy Structural Tubing with Improved Atmospheric Corrosion Resistance《具有增强耐大气腐蚀性能.pdf
  • ASTM A847 A847M-2014 Standard Specification for Cold-Formed Welded and Seamless High-Strength Low-Alloy Structural Tubing with Improved Atmospheric Corrosion Resistance《具有增强耐大气腐蚀性能.pdf ASTM A847 A847M-2014 Standard Specification for Cold-Formed Welded and Seamless High-Strength Low-Alloy Structural Tubing with Improved Atmospheric Corrosion Resistance《具有增强耐大气腐蚀性能.pdf
  • ASTM A848-2001(2006) Standard Specification for Low-Carbon Magnetic Iron《低碳磁铁的标准规范》.pdf ASTM A848-2001(2006) Standard Specification for Low-Carbon Magnetic Iron《低碳磁铁的标准规范》.pdf
  • ASTM A848-2001(2011) Standard Specification for Low-Carbon Magnetic Iron《低碳磁铁的标准规范》.pdf ASTM A848-2001(2011) Standard Specification for Low-Carbon Magnetic Iron《低碳磁铁的标准规范》.pdf
  • ASTM A848-2017 Standard Specification for Low-Carbon Magnetic Iron《低碳磁铁的标准规格》.pdf ASTM A848-2017 Standard Specification for Low-Carbon Magnetic Iron《低碳磁铁的标准规格》.pdf
  • ASTM A849-2000(2005) Standard Specification for Post-Applied Coatings Pavings and Linings for Corrugated Steel Sewer and Drainage Pipe《波纹钢排水管和污水管用后涂覆铺面和衬里材料标准规范》.pdf ASTM A849-2000(2005) Standard Specification for Post-Applied Coatings Pavings and Linings for Corrugated Steel Sewer and Drainage Pipe《波纹钢排水管和污水管用后涂覆铺面和衬里材料标准规范》.pdf
  • 相关搜索

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

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