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

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

1、国家三级(网络技术)机试模拟试卷 25及答案与解析 一、程序设计题 1 读函数 readDat()的功能是从文件 IN25.DAT中读取 20行数据存放到字符串数组xx中 (每行字符串长度均小于 80)。请编制函数 jsSort(),该函数的功能是:以行为单位对字符串按下面给定的条件进行排序,排序后的结果仍按行重新存入字符串数组 xx中,最后调用写函数 writeDat()把结果 xx输出到文件 OUT25.DAT中。 条件:从字符串中间一分为二,左边部分按字符的 ASCII值升序排序,排序后,左边部分与右边部分按例子 所示进行交换。如果原字符串长度为奇数,则最中间的字符不参加处理,字符仍放在

2、原位置上。 例如: 位置 0 1 2 3 4 5 6 7 8 源字符串 d c b a h g f e 4 3 2 1 9 8 7 6 处理后字符串 h g f e a b c d 9 8 7 6 1 2 3 4 注意:部分源程序已给出。 请勿改动主函数 main()、读函数 readDat()和写函数 writeDat()的内容。 试题程序: #include stdio.h #include string.h #include conio.h char xx20 80; void jsSort() main ( ) readDat (); jsSort (); writeDat (); r

3、eadDat ( ) FILE *in; int i=0; char *p; in = fopen(“IN25.DAT“, “r“); while(i 20 if(p) *p = 0; i+; fclose(in); writeDat () FILE *out; int i; clrscr (); out = fopen(“OUT25.DAT“, “w“); for(i=0; i 20; i+) printf(“%sn“, xxi); fprintf(out, “%sn“, xxi); fclose (out); 国家三级(网络技术)机试模拟试卷 25答案与解析 一、程序设计题 1 【正确答案

4、 void jsSort() int i,j,k,strl,half; char ch; for(i=0; i 20; i+) strl=strlen(xxi); /*求字符串的长度 */ half=str1/2; /*确定各行中字符串的中间位置 */ for(j=0;j half-1;j+) /*对中间位置以前的字符进行升序排序 */ for(k=j+1;k half;k+) if (xxijxxik) ch=xxij; xxij=xxik; xxik=ch; for(j=half-1,k=str1-1;j=0;j-,k-) /*将左边部分与右边部分对应的字符进行交换 */ ch=xxij

5、 xxij=xxik; xxik=ch; 【试题解析】 本题考查对二维字符数组的处理。由于对二维字符数组的操作是按照先行后列的顺序,因此,需要首先求得各行字符串的长度 (利用求字符 串长度的strlen()函数 ),然后借助循环结构逐个访问各行中的每一个字符。在本题中,应先确定各行中字符串的中间位置 (长度的一半就是中间位置 ),然后先对中间位置以前的字符进行升序排序,排序过程如下:依次用每一个位置的字符与它后面的所有字符 (到中间位置前一个字符结束 )进行比较,如果发现某字符的 ASCII码值小于当前被比较的字符的 ASCII码值,则将发现的字符与当前字符进行交换,交换后继续与其后面的字符进行比较。最终比较所得的结果是第一个位置总是存放着最小的字符,第二个位置总是存放着稍大的字符,以此类推就实现了 从小到大的排序功能。接着要做的工作是把中间位置前的一个位置定为初始位置,字符串中的最后一个位置也视为初始位置,让两个位置所对应的字符进行交换,交换过后,这两个位置值 (也就是下标值 )分别前移,再进行对应位置字符的交换。

展开阅读全文
相关资源
猜你喜欢
  • AECMA PREN 3987-2007 Aerospace series Test methods for metallic materials Constant amplitude force-controlled high cycle fatigue testing Edition P 1《航空航天系列.金属材料的试验方法 等幅控制应变低循环疲劳试验》.pdf AECMA PREN 3987-2007 Aerospace series Test methods for metallic materials Constant amplitude force-controlled high cycle fatigue testing Edition P 1《航空航天系列.金属材料的试验方法 等幅控制应变低循环疲劳试验》.pdf
  • AECMA PREN 3988-1998 Aerospace Series Test Methods for Metallic Materials Constant Amplitude Strain-Controlled Low Cycle Fatigue Testing Edition P 1《航空航天系列.金属材料的试验方法 等幅控制应变低循环疲劳试验》.pdf AECMA PREN 3988-1998 Aerospace Series Test Methods for Metallic Materials Constant Amplitude Strain-Controlled Low Cycle Fatigue Testing Edition P 1《航空航天系列.金属材料的试验方法 等幅控制应变低循环疲劳试验》.pdf
  • AECMA PREN 3989-1997 Aerospace Series Steel FE-PA2801 (X60NiMnCr13-5-3) Cold Workde and Stress Relieved Bar for Machining De Less Than or Equal to 30 mm Rm Greater Than or Equal to.pdf AECMA PREN 3989-1997 Aerospace Series Steel FE-PA2801 (X60NiMnCr13-5-3) Cold Workde and Stress Relieved Bar for Machining De Less Than or Equal to 30 mm Rm Greater Than or Equal to.pdf
  • AECMA PREN 3990-1997 Aerospace Series Steel FE-PA2801 (X60NiMnCr13-5-3) Softened Bar for Machining De Less Than or Equal to 150 mm 620 MPa Less Than or Equal to Rm Less Than or Equ.pdf AECMA PREN 3990-1997 Aerospace Series Steel FE-PA2801 (X60NiMnCr13-5-3) Softened Bar for Machining De Less Than or Equal to 150 mm 620 MPa Less Than or Equal to Rm Less Than or Equ.pdf
  • AECMA PREN 3991-1997 Aerospace Series Steel FE-PA2801 (X60NiMnCr13-5-3) Non Heat Treated Forging Stock a or D Less Than or Equal to 350 mm Edition P 1《航空航天系列.FE-PA2801(X60NiMnCr13-.pdf AECMA PREN 3991-1997 Aerospace Series Steel FE-PA2801 (X60NiMnCr13-5-3) Non Heat Treated Forging Stock a or D Less Than or Equal to 350 mm Edition P 1《航空航天系列.FE-PA2801(X60NiMnCr13-.pdf
  • AECMA PREN 3992-1997 Aerospace Series Steel FE-PA2801 (X60NiMnCr13-5-3) Softened Forgings De Less Than or Equal to 150 mm 620 MPa Less Than or Equal to Rm Less Than or Equal to 900.pdf AECMA PREN 3992-1997 Aerospace Series Steel FE-PA2801 (X60NiMnCr13-5-3) Softened Forgings De Less Than or Equal to 150 mm 620 MPa Less Than or Equal to Rm Less Than or Equal to 900.pdf
  • AECMA PREN 3993-1997 Aerospace Series Steel FE-CM1501 (X13CrNiMoCo12-3-2-2) Hardened and Tempered Precision and Sand Castings De Less Than or Equal to 150 mm Rm Greater Than or Equ.pdf AECMA PREN 3993-1997 Aerospace Series Steel FE-CM1501 (X13CrNiMoCo12-3-2-2) Hardened and Tempered Precision and Sand Castings De Less Than or Equal to 150 mm Rm Greater Than or Equ.pdf
  • AECMA PREN 3994-1997 Aerospace Series Steel FE-CM1501 (X13CrNiMoCo12-3-2-2) Non Heat Treated Remelting Stock Edition P 1《航空航天系列.FE-CM1501(X13CrNiMoCo12-3-2-2)非热处理钢 再熔原料》.pdf AECMA PREN 3994-1997 Aerospace Series Steel FE-CM1501 (X13CrNiMoCo12-3-2-2) Non Heat Treated Remelting Stock Edition P 1《航空航天系列.FE-CM1501(X13CrNiMoCo12-3-2-2)非热处理钢 再熔原料》.pdf
  • AECMA PREN 3996-1993 Aerospace Series Aluminium AL-P1100-H14 Sheet and Strip 0 3 mm Less Than or Equal to a Less Than or Equal to 6 mm Edition P1《航空航天系列.AL-P1100-H14型铝合金 0 3mm<a小于或.pdf AECMA PREN 3996-1993 Aerospace Series Aluminium AL-P1100-H14 Sheet and Strip 0 3 mm Less Than or Equal to a Less Than or Equal to 6 mm Edition P1《航空航天系列.AL-P1100-H14型铝合金 0 3mm<a小于或.pdf
  • 相关搜索

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

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