[计算机类试卷]国家二级C语言机试(操作题)模拟试卷212及答案与解析.doc

上传人:inwarn120 文档编号:498138 上传时间:2018-11-28 格式:DOC 页数:5 大小:31KB
下载 相关 举报
[计算机类试卷]国家二级C语言机试(操作题)模拟试卷212及答案与解析.doc_第1页
第1页 / 共5页
[计算机类试卷]国家二级C语言机试(操作题)模拟试卷212及答案与解析.doc_第2页
第2页 / 共5页
[计算机类试卷]国家二级C语言机试(操作题)模拟试卷212及答案与解析.doc_第3页
第3页 / 共5页
[计算机类试卷]国家二级C语言机试(操作题)模拟试卷212及答案与解析.doc_第4页
第4页 / 共5页
[计算机类试卷]国家二级C语言机试(操作题)模拟试卷212及答案与解析.doc_第5页
第5页 / 共5页
亲,该文档总共5页,全部预览完了,如果喜欢就下载吧!
资源描述

1、国家二级 C语言机试(操作题)模拟试卷 212及答案与解析 一、程序填空题 1 函数 fun的功能是:将一副扑克牌编号为 1, 2, 3, , 53, 54,以某种特定的方式洗牌,这种方式是将这副牌分成两半,然后将它们交叉,并始终保持编号为 1的牌在最上方,如第一次这样洗牌后的结果为: 1, 28, 2, 29, , 53, 27, 54。两次洗牌后的结果为: 1, 41, 28, 15, 2, 42 , 53, 40, 27, 14, 54。 程序的功能是:输出经过 n次这样洗牌后的结果。 请在程序的下画线处填入正确的内容,并把下画线删除 ,使程序得出正确的结果。 注意:源程序存放在考生文件

2、夹下的 BLANK1 C中。不得增行或删行,也不得更改程序的结构 ! 试题程序: 1 #inclucte stdio h 2 void fun(int a55, int n) 3 int i, k; 4 * found* 5 int 【 1】 55; 6 for(i=0; i n; i+) 7 for(k=1 ; k =27; k+) 8 b2* k-1 =a k; 8 b2*k-1=ak; 9 *found* 10 b【 2】 *k=ak+27; 11 12 for(k=1; k =54 ; k+) 13 *found* 14 ak= 【 3】 ; 15 16 17 main() 18 in

3、t m, a55, i; 19 for(i=1; i 55; i+)ai=i; printf(请输入洗牌次数: ); 20 scanf( d, m); 21 fun(a, m); 22 for(i=1; i 55; i+) printf( d, , ai); 23 printf( n); 24 二、程序修改题 2 下列给定程序中,函数 fun的功能是:读入一个字符串 (长度 0; i-) (2)if(tj tj+1) 【试题解析】 (1)本题是利用选择法对数组元素进行比较排序。所谓选择法,是依次用当前取得的元素和其后面的元素进行比较,在第一个元素和其后面的元素顺次比较时,可以借助中间变量来对两

4、个数进行交换,要保证第一个元素始终存放数组中的最大数,以后依次挑选出次大数,这样最终的数组就是有序的。 strlen函数所求得的字符串长度包括字符串结束符,所以要减 1。 (2)这里是一个分析逻辑错误,题中要求按升序排序,所以应改为 if(tjtj+1)。 三、程序设计题 3 【正确答案】 1 void fun(char aMN, char*b) 2 3 int i, j, k=0; 4 for(i=0; iM; i+) *将字符串数组中的 M个字符串,按顺序存入一个新的字符串 * 5 for(j=0; aij!= 0; j+) 6 bk+=aij; 7 bk= 0; *在字符串最后加上字符串结束标记符 * 8 【试题解析】 本题考查:字符串连接操作。本程序中第 1个 for循环的作用是对二维数组行的控制,第 2个循环的作用是从同一行中取出 字符并存放到一维数组 b中,语句是 bk+=aij;。

展开阅读全文
相关资源
猜你喜欢
  • ASTM B729-2005(2014) Standard Specification for Seamless UNS N08020 UNS N08026 and UNS N08024 Nickel-Alloy Pipe and Tube《UNS N0820 UNS NO8026和UNS NO8024无缝镍合金管的标准规格》.pdf ASTM B729-2005(2014) Standard Specification for Seamless UNS N08020 UNS N08026 and UNS N08024 Nickel-Alloy Pipe and Tube《UNS N0820 UNS NO8026和UNS NO8024无缝镍合金管的标准规格》.pdf
  • ASTM B730-2008 Standard Specification for Welded Nickel (UNS N02200 UNS N02201) and Nickel Copper Alloy (UNS N04400) Tube《焊接镍(N02200 UNS N02201)和镍铜合金管(UNS N04400)的标准规范》.pdf ASTM B730-2008 Standard Specification for Welded Nickel (UNS N02200 UNS N02201) and Nickel Copper Alloy (UNS N04400) Tube《焊接镍(N02200 UNS N02201)和镍铜合金管(UNS N04400)的标准规范》.pdf
  • ASTM B730-2008(2013) Standard Specification for Welded Nickel (UNS N02200 UNS N02201) and Nickel Copper Alloy (UNS N04400) Tube《焊接镍(N02200 UNS N02201)和镍铜合金管(UNS N04400)的标准规格》.pdf ASTM B730-2008(2013) Standard Specification for Welded Nickel (UNS N02200 UNS N02201) and Nickel Copper Alloy (UNS N04400) Tube《焊接镍(N02200 UNS N02201)和镍铜合金管(UNS N04400)的标准规格》.pdf
  • ASTM B731-1996(2006) Standard Specification for 60 % Palladium-40 % Silver Electrical Contact Material《60%钯40%银电触点材料标准规范》.pdf ASTM B731-1996(2006) Standard Specification for 60 % Palladium-40 % Silver Electrical Contact Material《60%钯40%银电触点材料标准规范》.pdf
  • ASTM B731-1996(2012) Standard Specification for 60&thinsp % Palladium-40&thinsp % Silver Electrical Contact Material 《60%钯40%银电触点材料标准规格》.pdf ASTM B731-1996(2012) Standard Specification for 60&thinsp % Palladium-40&thinsp % Silver Electrical Contact Material 《60%钯40%银电触点材料标准规格》.pdf
  • ASTM B733-2004 Standard Specification for Autocatalytic (Electroless) Nickel-Phosphorus Coatings on Metal《金属表面自催化(无电)镍磷涂层标准规范》.pdf ASTM B733-2004 Standard Specification for Autocatalytic (Electroless) Nickel-Phosphorus Coatings on Metal《金属表面自催化(无电)镍磷涂层标准规范》.pdf
  • ASTM B733-2004(2009) Standard Specification for Autocatalytic (Electroless) Nickel-Phosphorus Coatings on Metal《金属表面自催化(无电)镍磷涂层的标准规范》.pdf ASTM B733-2004(2009) Standard Specification for Autocatalytic (Electroless) Nickel-Phosphorus Coatings on Metal《金属表面自催化(无电)镍磷涂层的标准规范》.pdf
  • ASTM B733-2004(2014) Standard Specification for Autocatalytic (Electroless) Nickel-Phosphorus Coatings on Metal 《金属上自催化 (无电镀) 镍磷镀层的标准实施规程》.pdf ASTM B733-2004(2014) Standard Specification for Autocatalytic (Electroless) Nickel-Phosphorus Coatings on Metal 《金属上自催化 (无电镀) 镍磷镀层的标准实施规程》.pdf
  • ASTM B733-2015 Standard Specification for Autocatalytic (Electroless) Nickel-Phosphorus Coatings on Metal 《金属上自催化 (无电镀) 镍磷镀层的标准实施规程》.pdf ASTM B733-2015 Standard Specification for Autocatalytic (Electroless) Nickel-Phosphorus Coatings on Metal 《金属上自催化 (无电镀) 镍磷镀层的标准实施规程》.pdf
  • 相关搜索

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

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