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

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

1、国家三级(网络技术)机试模拟试卷 30及答案与解析 一、程序设计题 1 在文件 IN30.DAT中有 200组数据,每组有 3个数,每个数均是 3位数。函数readDat()是读取这 200组数据存放到结构数组 aa中。请编制函数 jsSort(),其函数的功能是:要求在 200组数据中找出条件为每组数据中的第二个数大于第一个数加第三个数之和,其中满足条件的个数作为函数 jsSort()的返回值,同时把满足条件的数据存入结构数组 bb中,再对结构数组 bb中的数据按照每组数据的第二个数加第三个数之和的大小进行降序排列,排序后 的结果仍重新存入结构数组 bb中,最后调用函数 writeDat()

2、把结果 bb输出到文件 OUT30.DAT中。 注意:部分源程序已给出。 请勿改动主函数 main()、读函数 readDat()和写函数 writeDat()的内容。 试题程序: #include stdio.h #include string.h #include conio.h typede f struct int x1, x2, x3; Data; Data aa200, bb200; int jsSort () main ( ) int count; readDat (); count = jsSort (); /*返回满足条件的个数 */ writeDat (count); re

3、adDat ( ) FILE *in; int i; in = fopen(“IN30.DAT“, “r“); for(i=0; i 200; i+) fscanf(in,“%d %d %d“, fclose (in); writeDat (int count) FILE *out; int i; out= fopen(“OUT30.DAT“, “w“); clrscr (); for(i=0; i count; i+) printf(“%d, %d, %d 第二个数 +第三个数 =%dn“, bbi.x1, bbi.x2, bbi.x3, bbi.x2+bbi, x3); fprintf(o

4、ut, “%d, %5d, %dn“, bbi .x1, bbi .x2, bbi.x3); fclose (out); 国家三级(网络技术)机试模拟试卷 30答案与解析 一、程序设计题 1 【正确答案】 int jsSort() int i,cnt=0,j; Data ch; for(i=0;i 200; i+) if(aai.x2aai.x1+aai.x3) /*如果第二个数大于第一个数加第三个数之和 */ bbcnt=aai; /*则把该 组数据存入结构数组 bb中 */ cnt+; /*统计满足条件的数据的组数 */ for(i=0;i cnt-1;i+) /*对结构数组 bb中的数据

5、按照每组数据的第二个数 */ for(j=i+1;j cnt;j+) /*加第三个数之和的大小进行降序排列 */ if(bbi.x2+bbi.x3 bbj.x2+bbj.x3) ch=bbi; bbi=bbj; bbj=ch; return cnt; /*返回满足条件的个数 */ 【试题解析】 本题考查对结构体数组中的元素的各个域的操作。首先利用一个for循环来依次取得结构体数组中的各个元素,之后按照题目要求对当前的元素的各个 域进行条件判断,由语句 “if(aai.x2aai.x1+aai.x3)”来实现。如果该条件成立,则把被判断元素存放到数组 bb中去,当符合条件的所有元素被找完后,按照 “每组数据中的第二个数加第三个数之和的大小 ”进行从大到小的排序。解答本题的关键是要弄清被处理对象是结构体变量中的某个域,而不是结构体变量本身。

展开阅读全文
相关资源
猜你喜欢
  • BS PD IEC TS 62763-2013_5284 Pilot function through a control pilot circuit using PWM (pulse width modulation) and a control pilot wire《通过控制导向线使用PWM (脉冲宽度调制) 的导向功能和控制导向线》.pdf BS PD IEC TS 62763-2013_5284 Pilot function through a control pilot circuit using PWM (pulse width modulation) and a control pilot wire《通过控制导向线使用PWM (脉冲宽度调制) 的导向功能和控制导向线》.pdf
  • BS ISO 8070-2007 Milk and milk products - Determination of calcium sodium potassium and magnesium contents - Atomic absorption spectrometric method《牛奶和奶制品 钙、钠、钾和镁含量的测定 原子吸.pdf BS ISO 8070-2007 Milk and milk products - Determination of calcium sodium potassium and magnesium contents - Atomic absorption spectrometric method《牛奶和奶制品 钙、钠、钾和镁含量的测定 原子吸.pdf
  • BS ISO 8082-1-2009 Self-propelled machinery for forestry - Laboratory tests and performance requirements for roll-over protective structures - General machines《林业用自推进机械 防倾.pdf BS ISO 8082-1-2009 Self-propelled machinery for forestry - Laboratory tests and performance requirements for roll-over protective structures - General machines《林业用自推进机械 防倾.pdf
  • BS ISO 8082-2-2011 Self-propelled machinery for forestry Laboratory tests and performance requirements for roll-over protective structures Machines having a rotating platf.pdf BS ISO 8082-2-2011 Self-propelled machinery for forestry Laboratory tests and performance requirements for roll-over protective structures Machines having a rotating platf.pdf
  • BS ISO 8083-2006 Machinery for forestry - Falling-object protective structures (FOPS) - Laboratory tests and performance requirements《林业机械 落体防护装置(FOPS) 实验室试验和性能要求》.pdf BS ISO 8083-2006 Machinery for forestry - Falling-object protective structures (FOPS) - Laboratory tests and performance requirements《林业机械 落体防护装置(FOPS) 实验室试验和性能要求》.pdf
  • BS ISO 8086-2004 Dairy plant - Hygiene conditions - General guidance on inspection and sampling procedures《乳品厂 卫生条件 检验和取样程序通用指南》.pdf BS ISO 8086-2004 Dairy plant - Hygiene conditions - General guidance on inspection and sampling procedures《乳品厂 卫生条件 检验和取样程序通用指南》.pdf
  • BS ISO 8096-2005 Rubber- or plastics-coated fabrics for water resistant clothing - Specification《雨衣用橡胶或塑料涂覆织物 规范》.pdf BS ISO 8096-2005 Rubber- or plastics-coated fabrics for water resistant clothing - Specification《雨衣用橡胶或塑料涂覆织物 规范》.pdf
  • BS ISO 8097-2001 Aircraft Minimum airworthiness requirements and test conditions for certified air cargo unit load devices《航空器 经认证的航空货运集装单元装置最低适航性要求和试验条件》.pdf BS ISO 8097-2001 Aircraft Minimum airworthiness requirements and test conditions for certified air cargo unit load devices《航空器 经认证的航空货运集装单元装置最低适航性要求和试验条件》.pdf
  • BS ISO 8114-1993 Textile machinery and accessories - Spindles for ring-spinning and doubling machines - List of equivalent terms《纺织机械和附件 环锭纺纱机和并线机用锭子 同义术语表》.pdf BS ISO 8114-1993 Textile machinery and accessories - Spindles for ring-spinning and doubling machines - List of equivalent terms《纺织机械和附件 环锭纺纱机和并线机用锭子 同义术语表》.pdf
  • 相关搜索

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

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