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

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

1、国家三级(网络技术)机试模拟试卷 26及答案与解析 一、程序设计题 1 已知数据文件 IN26.DAT中存有 200个 4位数,并已调用读函数 readDat()把这些数存入数组 a中。请编制一函数 jsVal(),其功能是:把千位数字和个位数字重新组成一个新的十位数 (新十位数的十位数字是原 4位数的千位数字,新十位数的个位数字是原 4位数的个位数字 ),把百位数字和十位数字组成另一个新的十位数 (新十位数的十位数字是原 4位数的百位数字,新十位数的个位数字是原 4位数的十位数字 ),如果新组成的两个十位数均是奇数并且两个十位数 中至少有一个数能被 5整除,同时两个新十位数字均不为零,则将满

2、足此条件的 4位数按从大到小的顺序存入数组 b中,并要求计算满足上述条件的 4位数的个数 cnt,最后调用写函数writeDat(),把结果 cnt及数组 b中符合条件的 4位数输出到 OUT26.DAT文件中。 注意:部分源程序已给出。 程序中已定义数组: a200, b200,已定义变量: cnt。 请勿改动主函数 main()、读函数 readDat()和写函数 writeDat()的内容。 试题程序: #include stdio.h #define MAX 200 int aMAX, bMAX, cnt = 0; void jsVal() void readDat() int i;

3、FILE *fp; fp = fopen(“IN26.DAT“, “r“); for(i = 0; i MAX; i+) fscanf(fp, “%d“, fclose (fp); main ( ) int i; readDat (); jsVal (); printf(“满足条件的数 =%dn“, cnt); for(i = 0; i cnt; i+) printf(“%d “, bi); printf (“n“); writeDat (); writeDat () FILE *fp; int i; fp = fopen(“OUT26.DAT“, “w“); fprintf(fp, “%dn

4、 cnt); for(i = 0; i cnt; i+) fprintf(fp, “%dn“, bi); fclose (fp); 国家三级(网络技术)机试模拟试卷 26答案与解析 一、程序设计题 1 【正确答案】 void jsVal() int i, thou, hun,ten,data,j; int ab, cd; for(i=0,i 200,i+) thou=ai/1000; /*求千位数字 */ hun=ai%1000/100; /*求百位数字 */ ten=ai%100/10; /*求十位数字 */ data=ai%10; /*求个位数字 */ ab=10*thou+data;

5、 /*把千位数字和个位数字重新组成一个新的十位数 */ cd=10*hun+ten; /*把百位数字和十位数字组成另一个新的十位数 */ if(ab%2=1 /*则把满足条件的数存入数组 b中 */ cnt+; for(i=0;i cnt-1;i+) /*将数组 b中的数按从大到小的顺序排列 */ for(j=i+1;j cnt;j+) if(bi bj) data=bi; bi=bj; bj=data; 【试题解析】 本题看起似乎比较繁琐,但只要仔细分析,把思路理清,还是不难解决的。由题意可以列出解题步骤如下: (1)求得当前所取得的整数的千位、百位、十位、个位上的数字值。可以借助 “/”(

6、除法 )与 “%” (取余 )两个运算符。 “thou=ai/1000; hun=ai%1000/100;ten=ai%100/10; data=ai%10; ”这 4条语句可以依次取得原 4位数的千位、百位、十位及个位上的数字值。 (2)按照要求 (第一个十位数:新十位数的十位数字是原 4位数的千位数字,新十位数的个位数字是原 4位数的个位数;第二个十位数:新十位数的十位数字是原 4位数的百位数字,新十位数的个位数字是原 4位数的十位数字 )把求得的各个位上的数字值组成两个新的十位数 ab和 cd,用 “ab=10*thou+data; cd=10*hun+ten; ”语句实现。 (3)对新组成的两个十位数进行条件判断 (判断条件的语句是“if(ab%2=1&cd%2=1& (ab%5=0|cd%5=0)& ab!=0 & cd!=0)”)。如果满足条件,则把原来的 4位数放到数组 b中,同时用一个计数器变量 cnt求出满足条件的 4位数的个数。 (4)对数组 b中的 4位数用选择法进行从大到小的排序。

展开阅读全文
相关资源
猜你喜欢
  • AECMA PREN 2667-1989 Test Method for the Determination of Water Absorption of Structural Foam Film Adhesives《航空航天系列结构用泡沫胶纸 吸水率测验》.pdf AECMA PREN 2667-1989 Test Method for the Determination of Water Absorption of Structural Foam Film Adhesives《航空航天系列结构用泡沫胶纸 吸水率测验》.pdf
  • AECMA PREN 2667-2-1996 Aerospace Series Non-Metallic Materials Foaming Structural Adhesives Test Methods Part 2 Compressive Tube Shear Edition P 1《航天系列包括非金属材料发泡结构胶粘剂的测试方法.第2部分 压缩管剪.pdf AECMA PREN 2667-2-1996 Aerospace Series Non-Metallic Materials Foaming Structural Adhesives Test Methods Part 2 Compressive Tube Shear Edition P 1《航天系列包括非金属材料发泡结构胶粘剂的测试方法.第2部分 压缩管剪.pdf
  • AECMA PREN 2667-3-1996 Aerospace Series Non-Metallic Materials Foaming Structural Adhesive Films Test Methods Part 3 Expansion Ratio and Volatile Content Edition P 1《航天系列包括非金属材料发泡结.pdf AECMA PREN 2667-3-1996 Aerospace Series Non-Metallic Materials Foaming Structural Adhesive Films Test Methods Part 3 Expansion Ratio and Volatile Content Edition P 1《航天系列包括非金属材料发泡结.pdf
  • AECMA PREN 2667-4-1996 Aerospace Series Non-Metallic Materials Foaming Structural Adhesive Films Test Methods Part 4 Vertical Slump Edition P 1《航天系列包括非金属材料发泡结构胶粘剂的测试方法.第4部分 垂直下跌.P1.pdf AECMA PREN 2667-4-1996 Aerospace Series Non-Metallic Materials Foaming Structural Adhesive Films Test Methods Part 4 Vertical Slump Edition P 1《航天系列包括非金属材料发泡结构胶粘剂的测试方法.第4部分 垂直下跌.P1.pdf
  • AECMA PREN 2667-5-1996 Aerospace Series Non-Metallic Materials Foaming Structural Adhesive Films Test Methods Part 5 Exothermicity Edition P 1《航天系列包括非金属材料发泡结构胶粘剂的测试方法.第5部分 放热.P1版》.pdf AECMA PREN 2667-5-1996 Aerospace Series Non-Metallic Materials Foaming Structural Adhesive Films Test Methods Part 5 Exothermicity Edition P 1《航天系列包括非金属材料发泡结构胶粘剂的测试方法.第5部分 放热.P1版》.pdf
  • AECMA PREN 2667-6-1989 Aerospace Series Test Method for the Determination of Water Absorption of Structural Foam Film Adhesives Issue P 1《航天系列测试法测定水吸收的结构性泡沫薄膜胶粘剂.P1版》.pdf AECMA PREN 2667-6-1989 Aerospace Series Test Method for the Determination of Water Absorption of Structural Foam Film Adhesives Issue P 1《航天系列测试法测定水吸收的结构性泡沫薄膜胶粘剂.P1版》.pdf
  • AECMA PREN 2669-1988 Aerospace Series Heat Resisting Nickel Base Alloy Ni-P96 Melted Under Vacuum Not Heat Treated Reference Heat Treatment Solution Treated and Precipitation Treat.pdf AECMA PREN 2669-1988 Aerospace Series Heat Resisting Nickel Base Alloy Ni-P96 Melted Under Vacuum Not Heat Treated Reference Heat Treatment Solution Treated and Precipitation Treat.pdf
  • AECMA PREN 2670-1988 Aerospace Series Heat Resisting Nickel Base Alloy Ni-P96 Melted Under Vacuum Solution Treated and Precipitation Treated Forgings Issue P 1《航空航天系列抗热镍基合金 Ni-P96真.pdf AECMA PREN 2670-1988 Aerospace Series Heat Resisting Nickel Base Alloy Ni-P96 Melted Under Vacuum Solution Treated and Precipitation Treated Forgings Issue P 1《航空航天系列抗热镍基合金 Ni-P96真.pdf
  • AECMA PREN 2671-1988 Aerospace Series Design and Construction of Pipelines for Fluids in Liquid or Gaseous Condition Outline and Terms Edition P 1《航空航天系列液体和气体状态流动设计和建筑管道 大纲和术语》.pdf AECMA PREN 2671-1988 Aerospace Series Design and Construction of Pipelines for Fluids in Liquid or Gaseous Condition Outline and Terms Edition P 1《航空航天系列液体和气体状态流动设计和建筑管道 大纲和术语》.pdf
  • 相关搜索

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

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