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

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

1、国家三级信息管理技术机试模拟试卷 71及答案与解析 一、程序设计题 1 函数 readDat()是从文件 in71.dat中读取 20行数据存放到字符串数组 xx中 (每行字符串长度均小于 80)。请编制函数 jsSon(),其功能是:以行为单位对字符串按下面给定的条件进行排序,排序后的结果仍按行重新存入字符串数组 xx中。最后调用函数 writeDat()把结果 xx输出到文件 out71.dat中。 条件:从字符串中间一分为二,左边部分按字符的 ASC 值降序排序,右边部分按字符的 ASC 值升序排序。如果原字符串长 度为奇数,则最中间的字符不参加排序,字符仍放在原位置上。 例如: 位置

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

3、 ); readDat ( ) FILE *in; int i=0; char *p; in=fopen ( “in71.dat“, “r“); while (i 20 if(p) *p=0; i+; fclose (in); writeDat ( ) FILE *out; int i; clrscr ( ); out=fopen ( “out71.dat“, “w“ ); for (i=0; i 20; i+) printf(“%sn“,xxi); fprintf (out, “%sn“ ,xxi ); fclose (out); 国家三级信息管理技术机试模拟试卷 71答案与解析 一、程序设

4、计题 1 【正确答案】 函数 readDat()是从文件 in71.dat中读取 20行数据存放到字符串数组 xx中 (每行字符串长度均小于 80)。请编制函数 jsSon(),其功能是:以行为单位对字符串按下面给定的条件进行排序,排序后的结果仍按行重新存入字符串数组xx中。最后调用函数 writeDat()把结果 xx输出到文件 out71.dat中。 条件:从字符串中间一分为二,左边部分按字符的 ASC 值降序排序,右边部分按字符的 ASC 值升序排序。如果原字符串长度为奇数,则最中间的字符不参加排序, 字符仍放在原位置上。 例如: 位置 0 1 2 3 4 5 6 7 8 源字符串 a

5、b c d h g f e 1 2 3 4 9 8 7 6 5 处理后的字符串 d c b a e f g h 4 3 2 1 9 5 6 7 8 注意:部分源程序已给出。 请勿改动主函数 main()、读函数 readDat()和写函数 writeDat()的内容。 试题程序: #include stdio. h # inc lude st ring. h #inc lude conio, h char xx20 80; void jsSort() void main ( ) readDat (); jsSort (); writeDat ( ); readDat ( ) FILE *in;

6、 int i=0; char *p; in=fopen ( “in71.dat“, “r“); while (i 20 if(p) *p=0; i+; fclose (in); writeDat ( ) FILE *out; int i; clrscr ( ); out=fopen ( “out71.dat“, “w“ ); for (i=0; i 20; i+) printf(“%sn“,xxi); fprintf (out, “%sn“ ,xxi ); fclose (out); 【试题解析】 本题考查的知识点如下: (1)二维数组的访问和下标的控制。 (2)字符的 ASC 码的比较。 (3)字符的排序。 本题将数据按行存入到二维数组 xx中,行数为数组的第 1个下标,每行字符的个数为数组的第 2个下标。因为以行为字符串处理的单位,所以要先求得一行字符串的长度。字符可以参加任何整数运算,实际上是字符的 ASC 码参与了运算,所以可以直接使用比较运算符对字符进行比较。对从 0到 (长度 /2-1)的字符进行降序排序 (数组的下标从 0开始 )。若长度为奇数,则再从 (长度 /2+1)开始 (跳过最中间的字符 )到最后 1个字符进行升序排列。否则,从 (长度 /2)开始到最后 1个字符进行升序排列。字符排序使用 “选择排序法 ”,最后使用循环实现对每行数据的处理。

展开阅读全文
相关资源
猜你喜欢
  • ANSI INCITS288-1999 Information Technology - Fibre Channel - Generic Services - 2 (FC-GS-2) Replaces ANSI NCITS 288-1999《信息技术.光纤信道-通用设备(FC-GS)(ANSI X3.288-1996的修订和重新设计)(以前为ANSI NCI.pdf ANSI INCITS288-1999 Information Technology - Fibre Channel - Generic Services - 2 (FC-GS-2) Replaces ANSI NCITS 288-1999《信息技术.光纤信道-通用设备(FC-GS)(ANSI X3.288-1996的修订和重新设计)(以前为ANSI NCI.pdf
  • ANSI INCITS30-1997 Information Technology - Representation of Date for Information Interchange《信息技术.信息交换用日期的表示法》.pdf ANSI INCITS30-1997 Information Technology - Representation of Date for Information Interchange《信息技术.信息交换用日期的表示法》.pdf
  • ANSI INCITS302-1998 Information Technology - SCSI Parallel Interface-2 (SPI-2)《信息技术.SCSI并行接口.2(SPI-2)》.pdf ANSI INCITS302-1998 Information Technology - SCSI Parallel Interface-2 (SPI-2)《信息技术.SCSI并行接口.2(SPI-2)》.pdf
  • ANSI INCITS303-1998 Information Technology - Fibre Channel - Physical and Signalling Interface-3 (FC-PH-3)《信息技术.光纤信道.物理和信令接口.3(FC-PH-3)》.pdf ANSI INCITS303-1998 Information Technology - Fibre Channel - Physical and Signalling Interface-3 (FC-PH-3)《信息技术.光纤信道.物理和信令接口.3(FC-PH-3)》.pdf
  • ANSI INCITS306-1998 Information Technology - SCSI-3 Block Commands (SBC)《信息技术.SCSI-3块指令(SBC)》.pdf ANSI INCITS306-1998 Information Technology - SCSI-3 Block Commands (SBC)《信息技术.SCSI-3块指令(SBC)》.pdf
  • ANSI INCITS31-2009 Information technology - Codes for the Identification of Counties and Equivalent Areas of the United States Puerto Rico and the Insular Areas《信息技术.美国 波多黎各地区以及海岛地.pdf ANSI INCITS31-2009 Information technology - Codes for the Identification of Counties and Equivalent Areas of the United States Puerto Rico and the Insular Areas《信息技术.美国 波多黎各地区以及海岛地.pdf
  • ANSI INCITS310-1998 Information Technology - Representation of Time for Information Interchange《信息技术.信息交换用时间的表示法》.pdf ANSI INCITS310-1998 Information Technology - Representation of Time for Information Interchange《信息技术.信息交换用时间的表示法》.pdf
  • ANSI INCITS311-1998 Information Technology - Magnetic Tape Format for Information Interchange - 128-Track Parallel Serpentine 12.65 mm (1 2 in) 3400 bpmm (86 360 bpi) Run Length Re.pdf ANSI INCITS311-1998 Information Technology - Magnetic Tape Format for Information Interchange - 128-Track Parallel Serpentine 12.65 mm (1 2 in) 3400 bpmm (86 360 bpi) Run Length Re.pdf
  • ANSI INCITS312-1998 Information Technology - Magnetic Tape Cartridge for Information Interchange - 0.50 in (12.65 mm) Serial Serpentine 128-Track 81 600 bpi (3212 bpmm) DLT4 Format.pdf ANSI INCITS312-1998 Information Technology - Magnetic Tape Cartridge for Information Interchange - 0.50 in (12.65 mm) Serial Serpentine 128-Track 81 600 bpi (3212 bpmm) DLT4 Format.pdf
  • 相关搜索

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

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