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

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

1、国家三级信息管理技术机试模拟试卷 44及答案与解析 一、程序设计题 1 已知数据文件 IN44.DAT中存有 300个 4位数,并已调用读函数 readDat()把这些数存入数组 a中,请编制一函数 jsValue(),其功能是:求出千位数上的数减百位数上数减十位数上的数减个位数上的数大于零的数的个数 cnt,再把所有满足此条件的 4位数依次存入数组 b中,然后对数组 b的 4位数按从小到大的顺序进行排序,最后调用写函数 writeDat()把数组 b中的数输出到 OUT44.DAT文件中。 例如: 9123, 9-1-2-3 0,则该数满足条件,存入数组 b中,且个数 cnt=cnt+1。

2、9812, 94-1-2 0,则该数不满足条件,忽略。 注意:部分源程序已给出。 程序中已定义数组: a300, b300,已定义变量: cnt。 请勿改动主函数 main()、读函数 readDat()和写函数 writeDat()的内容。 试题程序 #include stdio.h int a300,b300,cnt=0; jsvalue() main() int i; readDat(); jsValue(); writeDat(); for(i=0;i cnt; i+) printf(“b%d=%dn“, i, bi); readDat ( ) FILE *fp; int i; fp=

3、fopen(“IN44.DAT“,“r“); printf(“cnt=%dn“,cnt); for(i=0;i 300;i+) fscanf(fp,“%d,“, fclose(fp); writeDat () FILE *fp; int i; fp=fopen(“OUT44.DAT“,“w“); fprintf(fp,“%dn“,cnt); for(i=0;i cnt;i+) fprintf(fp, “%dn“,bi); fclose(fp); 国家三级信息管理技术机试模拟试卷 44答案与解析 一、程序设计题 1 【正确答案】 jsValue ( ) int i, thou, hun, ten

4、 data, j; for (i=0; i 300 ;i+) thou=a i/1000; /*求四位数的千位数字 */ hun=a i %1000/100; /*求四位数的百位数字 */ ten=a i %100/10; /*求四位数的十位数字 */ data=a i %10; /*求四位数的个位数字 */ if(thou-hun-ten-data 0) /*如果千位数减百位数减十位数减个位数大于零 */ b cnt=a i; /*则把该数存入 数级 b中 */ cnt+; /*统计满足条件的数的个数 */ for (i=0; i cnt-1; i+) /*对数组 b的 4位数按从小到大的

5、顺序进行排序 */ for (j=i+l; j cnt; j+) if(bi bj ) data=bi; bi=bj; bj=data; 【试题解析】 本题考查的知识点如下: (1)运算符 “%” 及 “/”的使用。 (2)循环结构及选择结构的使用。 在本题中,首先要将一个 4位数的千位、百位、十位、个位拆成独立的数字。这里借助特殊运算符号 “%”( 取余 )和 “/” (整除 )。将一个 4位数整除 1000则可得到其千位上的数字,除以 1000取余再整除 100则可得百位上的数字,除以 100取余再整除 10则可得十位上的数字,除以 10取余则得个位上的数字。然后按照题意要求将 各位依次相减进行判断。最后的排序采用 “选择排序法 ”。

展开阅读全文
相关资源
猜你喜欢
  • STAS SR ISO 787-10-1995 General methods of test for pigments and extenders -Part 10   Determination of density - Pyknorneter method《测试颜料和填料的一般方法.第10部分:密度的测定.比重瓶法》.pdf STAS SR ISO 787-10-1995 General methods of test for pigments and extenders -Part 10 Determination of density - Pyknorneter method《测试颜料和填料的一般方法.第10部分:密度的测定.比重瓶法》.pdf
  • STAS SR ISO 787-2-1981 General methods of test for pigments and extenders - Part 2  Determination of matter volatile at 105°C《测试颜料和填料的一般方法.第2部分:在105 ℃挥发性物质的测定》.pdf STAS SR ISO 787-2-1981 General methods of test for pigments and extenders - Part 2 Determination of matter volatile at 105°C《测试颜料和填料的一般方法.第2部分:在105 ℃挥发性物质的测定》.pdf
  • STAS SR ISO 787-3-1979 General methods of test for pigments and extenders- Part 3  Determination of matter soluble in water- Hot extraction method《测试颜料和填料的一般方法.第3部分:易溶于水物质的测定.热萃取法》.pdf STAS SR ISO 787-3-1979 General methods of test for pigments and extenders- Part 3 Determination of matter soluble in water- Hot extraction method《测试颜料和填料的一般方法.第3部分:易溶于水物质的测定.热萃取法》.pdf
  • STAS SR ISO 787-4-1981 General methods of test for pigments and extenders-Part 4  Determination of acidity or alkalinity of the aqueous extract《一般方法测试颜料和延伸,第4部分:测定酸度或碱度的水提物 》.pdf STAS SR ISO 787-4-1981 General methods of test for pigments and extenders-Part 4 Determination of acidity or alkalinity of the aqueous extract《一般方法测试颜料和延伸,第4部分:测定酸度或碱度的水提物 》.pdf
  • STAS SR ISO 787-5-1980 General methods of test for pigments and extenders Part 5  Determination of oil absorbtion value《测试颜料和填料的一般方法.第5部分:测定吸油值 》.pdf STAS SR ISO 787-5-1980 General methods of test for pigments and extenders Part 5 Determination of oil absorbtion value《测试颜料和填料的一般方法.第5部分:测定吸油值 》.pdf
  • STAS SR ISO 787-7-1994 General methods of test for pigments and extenders — Part 7  Determination of residue on sieve — Manual procedure《测试颜料和填料的一般方法.第7部分:测定筛残渣.手工操作程序》.pdf STAS SR ISO 787-7-1994 General methods of test for pigments and extenders — Part 7 Determination of residue on sieve — Manual procedure《测试颜料和填料的一般方法.第7部分:测定筛残渣.手工操作程序》.pdf
  • STAS SR ISO 787-8-1995 General methods of test for pigments and extenders -Part 8  Determination of matter soluble in water - Cold extraction《测试颜料和填料的一般方法.第8部分:溶于水物质的测定.冷萃取》.pdf STAS SR ISO 787-8-1995 General methods of test for pigments and extenders -Part 8 Determination of matter soluble in water - Cold extraction《测试颜料和填料的一般方法.第8部分:溶于水物质的测定.冷萃取》.pdf
  • STAS SR ISO 787-9-1995 General methods of test for pigments and extenders - Part S  Determination of pH value of an aqueous suspension《天然色素和添加剂测试的一般方法.第5部分:悬浮液的PH值测定》.pdf STAS SR ISO 787-9-1995 General methods of test for pigments and extenders - Part S Determination of pH value of an aqueous suspension《天然色素和添加剂测试的一般方法.第5部分:悬浮液的PH值测定》.pdf
  • STAS SR ISO 791-1995 Magnesium alloys Determination of aluminum 8-hydroxyquinoline gravimetric method《镁合金.测定铝.8.羟基喹啉重量法》.pdf STAS SR ISO 791-1995 Magnesium alloys Determination of aluminum 8-hydroxyquinoline gravimetric method《镁合金.测定铝.8.羟基喹啉重量法》.pdf
  • 相关搜索

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

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