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

上传人:roleaisle130 文档编号:498645 上传时间:2018-11-29 格式:DOC 页数:6 大小:31.50KB
下载 相关 举报
[计算机类试卷]国家二级C语言机试(操作题)模拟试卷66及答案与解析.doc_第1页
第1页 / 共6页
[计算机类试卷]国家二级C语言机试(操作题)模拟试卷66及答案与解析.doc_第2页
第2页 / 共6页
[计算机类试卷]国家二级C语言机试(操作题)模拟试卷66及答案与解析.doc_第3页
第3页 / 共6页
[计算机类试卷]国家二级C语言机试(操作题)模拟试卷66及答案与解析.doc_第4页
第4页 / 共6页
[计算机类试卷]国家二级C语言机试(操作题)模拟试卷66及答案与解析.doc_第5页
第5页 / 共6页
点击查看更多>>
资源描述

1、国家二级 C语言机试(操作题)模拟试卷 66及答案与解析 一、程序填空题 1 函数 fun的功能是:把形参 a所指数组中的最大值放在 a0中,接着求出 a所指数组中的最小值放在 a1中;再把 a所指数组元素中的次大值放在 a2中,把 a数组元素中的次小值放在 a3中;其余以此类推。例如:若 a所指数组中的数据最初排列为: 1、 4、 2、 3、 9、 6、 5、 8、 7,则按规则移动后,数据排列为: 9、 1、 8、2、 7、 3、 6、 4、 5。形参 n中存放 a所指数组中数据的个数。 请在程序的下划线处填入正确的内容并把下划线删除 ,使程序得出正确的结果。 注意:源程序存放在考生文件夹

2、下的 BLANK1 C 中。 不得增行或删行,也不得更改程序的结构 ! #inolude #define N 9 /*found*/ void fun(int _1_, int n) int i, j, max, min, px, pn, t ; /*found*/ for (i=0 ; iaj) min=aj; pn=j; ) i f(px!=i) t=ai; ai=max ; apx=t; i f(pn=i)pn=px ; i f(pn!=i+1) t=a2+1; a2+1=min; apn=t; ) main() int bN=1, 4, 2, 3, 9, 6, 5, 8, 7), i

3、; printf(“nThe original data: n“); for(i=0; i #define SIZE 20 fun(double*s, double*w) int k, i; double sum; for(k=2, i=0; i #define N 8 typedef struct char nLlm10; double s; STREC; double fun(STREC*a, STREC*b, int*n) main() STREC SN=“GA05“, 85), “GA03“, 76, “GA02“, 69, “GA04“, 85), “GA01“, 91, “GA07

4、“, 72), “GA08“, 64), “GA06“, 87; STREC hN, t; FILE*out; int i, j, n; double ave; ave=fun(s, h, &n); printf(“The d student data which is lower than 7 3f: n“, r1, ave), for(i=0; ihj s)t=hi; hi=hj; hj=t; for(i=0; in; i+) fprintf(out, “ 4 1fn“, hi s); fclose(out); 国 家二级 C语言机试(操作题)模拟试卷 66答案与解析 一、程序填空题 1

5、【正确答案】 (1)*a (2)2 (3)i+1 【试题解析】 第一空:主函数内 fun函数的调用 “fun(b, N); ”,其中 b为整型数组名,故 fun函数的第一参数为整型指针,又根据 “max=aj”可知第一个参数名为 a,故第一空处为 “*a”。 第二空:根据题意 a所指数组中的最大值放在 a0中,接着求出 a所指数组中的最小值放在 a1中;再把 a所指数组元素中的次大值放在 a2中,把 a数组元素中的次小值放在 a3中,升序排序 和降序排序的下标变化是每次在前一次的基础上+2,即 a0、 a2、 a4 降序排序, a1、 a3、 a5 升序排序,故第二空应为“2”。 第三空:选择

6、排序法中的升序排序,首先从数组中挑选一个最小的元素,把它和第一元素交换,接着从剩下的 n-1个元素中再挑出一个最小的元素,把它和第二个元素交换,不断重复以上过程,直到比较完最后两个元素。故内层循环变量 i应该从 i+1开始,因此第三空处应为 “i+1”。 二、程序修改题 2 【正确答案】 (1)sum=0 0; (2)if(i+1) 5=0) 【试题解析】 (1)在第一标识下 “sun=0 0; ”,根据题意,这是给 sum赋值,而sun没有定义编译时会提示错误,应改为 “sum=0 0; ”。 (2)错误标识下的 if判断语句是依顺序取 5个字符, if中的逻辑表达式语法有误,由于 1 5恒

7、等于 1,所以 i+1 5也就等价于 i+1了,所以将 “if(i+1 5=0)”改为“if(i+1) 5=0)”,此处主要注意的是运算符的优先级。 三、程序设计题 3 【正确答案】 int i; double ave=0 0; *n=0; for(i=0; iN; i+)ave=ave+ai s; ave/=N; /*计算平均值 */ for(i=0; iN; i+) if(ai save) /*把低于平均值的记录存放到 b所指的数组中 */ b*n=ai; (*n)+; /*人数加 1*/ return ave; /*返回平均值 */ 【试题解析】 (1)首先,通过循环求总分,然后求得平均分。 (2)在循环中,进行平均分与每个成绩进行比较,并将满足条件的数据存入数组及对其进行累加。

展开阅读全文
相关资源
猜你喜欢
  • ASTM B754-2010(2015)e1 Standard Test Method for Measuring and Recording the Deviations from Flatness in Copper and Copper Alloy Strip《铜及铜合金带材平面偏差的测量和记录标准试验方法》.pdf ASTM B754-2010(2015)e1 Standard Test Method for Measuring and Recording the Deviations from Flatness in Copper and Copper Alloy Strip《铜及铜合金带材平面偏差的测量和记录标准试验方法》.pdf
  • ASTM B754-2017 Standard Test Method for Measuring and Recording the Deviations from Flatness in Copper and Copper Alloy Strip《铜及铜合金带材平面偏差的测量和记录标准试验方法》.pdf ASTM B754-2017 Standard Test Method for Measuring and Recording the Deviations from Flatness in Copper and Copper Alloy Strip《铜及铜合金带材平面偏差的测量和记录标准试验方法》.pdf
  • ASTM B755-2000(2006) Standard Specification for Nickel-Chromium-Molybdenum-Tungsten Alloys (UNS N06110) Plate Sheet and Strip《镍铬钼钨合金板、薄板和带材标准规范》.pdf ASTM B755-2000(2006) Standard Specification for Nickel-Chromium-Molybdenum-Tungsten Alloys (UNS N06110) Plate Sheet and Strip《镍铬钼钨合金板、薄板和带材标准规范》.pdf
  • ASTM B755-2000(2011) Standard Specification for Nickel-Chromium-Molybdenum-Tungsten Alloys (UNS N06110) Plate Sheet and Strip《镍铬钼钨合金(UNS N06110)中厚板 薄板和条板标准规格》.pdf ASTM B755-2000(2011) Standard Specification for Nickel-Chromium-Molybdenum-Tungsten Alloys (UNS N06110) Plate Sheet and Strip《镍铬钼钨合金(UNS N06110)中厚板 薄板和条板标准规格》.pdf
  • ASTM B755-2000(2016) Standard Specification for Nickel-Chromium-Molybdenum-Tungsten Alloys (UNS N06110) Plate Sheet and Strip《镍铬钼钨合金 (UNS N06110) 板材 薄板材和带材的标准规格》.pdf ASTM B755-2000(2016) Standard Specification for Nickel-Chromium-Molybdenum-Tungsten Alloys (UNS N06110) Plate Sheet and Strip《镍铬钼钨合金 (UNS N06110) 板材 薄板材和带材的标准规格》.pdf
  • ASTM B756-2000(2006) Standard Specification for Nickel-Chromium-Molybdenum-Tungsten Alloy (UNS N06110) Rod and Bar《镍铬钼钨合金(UNS N06110)棒材和杆材标准规范》.pdf ASTM B756-2000(2006) Standard Specification for Nickel-Chromium-Molybdenum-Tungsten Alloy (UNS N06110) Rod and Bar《镍铬钼钨合金(UNS N06110)棒材和杆材标准规范》.pdf
  • ASTM B756-2000(2011) Standard Specification for Nickel-Chromium-Molybdenum-Tungsten Alloy (UNS N06110) Rod and Bar《镍铬钼钨合金(UNS N06110)条材及棒材的标准规格》.pdf ASTM B756-2000(2011) Standard Specification for Nickel-Chromium-Molybdenum-Tungsten Alloy (UNS N06110) Rod and Bar《镍铬钼钨合金(UNS N06110)条材及棒材的标准规格》.pdf
  • ASTM B756-2000(2016) Standard Specification for Nickel-Chromium-Molybdenum-Tungsten Alloy(UNS N06110) Rod and Bar《镍铬钼钨合金 (UNS N06110) 杆材和棒材的标准规格》.pdf ASTM B756-2000(2016) Standard Specification for Nickel-Chromium-Molybdenum-Tungsten Alloy(UNS N06110) Rod and Bar《镍铬钼钨合金 (UNS N06110) 杆材和棒材的标准规格》.pdf
  • ASTM B757-2000(2006) Standard Specification for Nickel-Chromium-Molybdenum-Tungsten-Alloys (UNS N06110) Welded Pipe《镍铬钼钨合金焊接管标准规范》.pdf ASTM B757-2000(2006) Standard Specification for Nickel-Chromium-Molybdenum-Tungsten-Alloys (UNS N06110) Welded Pipe《镍铬钼钨合金焊接管标准规范》.pdf
  • 相关搜索

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

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