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

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

1、国家二级( C语言)机试模拟试卷 285及答案与解析 一、程序填空题( 30分) 1 给定程序中,函数 fun的功能是:在形参 ss所指字符串数组中,将所有串长超过 k的字符串中右边的字符删除,只保留左边的 k个字符。 ss所指字符串数组中共有 N个字符串,且串长小于 M。 请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。 注意:源程序存放在考生文件夹下的 BLANK1 C中。 不得增行或删行,也不得更改程序的结构 ! #include #include #define N 5 #define M 10 *found* void fun(char(*ss) 【 1】 ,

2、int k) ( int i=0 ; /*found*/ while(i #include int fun(int n, int*value) int d, s, i; *found* d=0; s=0; for(i=1; i=8); sum=fun(n, &v); printf(“ n nThe result: n value= d sum= d n n“, v, sum); 三、程序设计题( 40分) 3 学生的记录由学号和成绩组成, N名学生的数据已在主函数中放入结构体数组 s中,请编写函数 fun,它的功能是: 把分数最高的学生数据放在 h所指的数组中,注意:分数最 高的学生可能不止

3、一个,函数返回分数最高的学生的人数。 注意:部分源程序在文件 PROGl C中。 请勿改动主函数 main和其他函数中的任何内容,仅在函数 fun的花括号中填入你编写的若干语句。 #include #defihe N 16 typedef struct char num10; int s; STREC; int fun(STREC * a, STREC * b) main() STRBC sN=“GA05“, 85, “GA03“, 76, “GA02“, 69, “GA04“, 85, “GA01“, 91, “GA07“, 72, “GA08“, 64, “GA06“, 87, “GA01

4、5“, 85, “GA013“, 91, “GA012“, 64, “GA014“, 91, “GA011“, 77, “GA017“, 64, “GA018“, 64, “GA016“, 72; STREC hN; int i, n; FILE * out ; n=fun(s, h); printf “The d highest score: n“, n); for(i=0; in; i+) printf(“ s 4d n“, hi num, hi s); printf(“ n“); out=fopen(“out dat“, “w“); fprintf(out, “ d n“, n); fo

5、r(i=0, in; i+) fprintf(out, “ 4d n“, hi s); fclose(out); 国家二级( C语言)机试模拟试卷 285答案与解析 一、程序填空题( 30分) 1 【正确答 案】 【 1】 M 【 2】 N 【 3】 0或 0 【试题解析】 第一空:第一空补充函数定义,在主函数内 fun函数的调用形式是“fun(x,4)“, x是二维数组名,故 fun函数的第一参数是指向二维数组的指针,因此第一空为 “M“。 第二空: “while(i2)“是填循环终止条件,根据题意, fun函数是将所有串长超过 k的字符串中右边的字符删除,因此循环次数为 N,故第二空处为

6、“N“。 第三空: “ssik=【 3】; i+; “是将串长超过 k的字符串中右边的字符删除,即在 ssik位置为 0或 “0“。 二、程序修改题( 30分) 2 【正确答案】 (1)d=1; s=0; (2)d=d 10; 【试题解析】 (1)第一个标识下的 “d=0: “求出的次方一直是 0,所以将 “d=0: “改为 “d=1“。 (2)第二个标识下的 “d=d10; “是对 d的截取,这里的 “ “本意应该是除号,但这个在 C语言中是不可识别的,所以第二个标识下 “d=d 10; “应该改为 “d=d10; “。 三、程序设计题( 40分) 3 【正确答案】 int i, max=a0 s, n=0; for(i=1; iN; i+) if(maxai s)max=ai s; *找出最高成绩 * for(i=0; iN; i+) if(max=ai s)bn+=ai; *找相等的最高成绩并存入数组 b中 * return n: *返回符合条件的人数 * 【试题解析】 (1)要把最高分数的学生数据放在数组中,首先求出最高分数,再使用一个 for循环把所有的成绩进行比较,找出最高的分数来。 (2)找出所有与最高分数相等的学生 ,并将最高分数的人数累加。

展开阅读全文
相关资源
猜你喜欢
  • ASD-STAN PREN 3948-1994 Aerospace Series Nickel Base Alloy NI-B15701 Filler Metal for Brazing Wire (Edition P 1)《航空航天系列 钎焊丝用镍基合金NI-B15701填料金属 第P1版》.pdf ASD-STAN PREN 3948-1994 Aerospace Series Nickel Base Alloy NI-B15701 Filler Metal for Brazing Wire (Edition P 1)《航空航天系列 钎焊丝用镍基合金NI-B15701填料金属 第P1版》.pdf
  • ASD-STAN PREN 3951-1993 Aerospace Series Silver Base Alloy AG-B32101 Filler Metal for Brazing Rolled Foil (Issue P1)《航空航天系列 钎焊用银基合金AG-B32101填料金属 压延箔膜 第P1版》.pdf ASD-STAN PREN 3951-1993 Aerospace Series Silver Base Alloy AG-B32101 Filler Metal for Brazing Rolled Foil (Issue P1)《航空航天系列 钎焊用银基合金AG-B32101填料金属 压延箔膜 第P1版》.pdf
  • ASD-STAN PREN 3952-2001 Aerospace Series Silver Base Alloy AG-B10001 Filler Metal for Brazing Wire (Edition P 2 Supersedes Edition P 1 January 1994 Replaced by EN 3952)《航空航天系列 银基合金.pdf ASD-STAN PREN 3952-2001 Aerospace Series Silver Base Alloy AG-B10001 Filler Metal for Brazing Wire (Edition P 2 Supersedes Edition P 1 January 1994 Replaced by EN 3952)《航空航天系列 银基合金.pdf
  • ASD-STAN PREN 3953-2001 Aerospace Series Silver Base Alloy AG-B12401 Filler Metal for Brazing Wire (Edition P 2 Supersedes Edition P 1 January 1994)《航空航天系列 银基合金AG-B12401制填料金属 线料 第P.pdf ASD-STAN PREN 3953-2001 Aerospace Series Silver Base Alloy AG-B12401 Filler Metal for Brazing Wire (Edition P 2 Supersedes Edition P 1 January 1994)《航空航天系列 银基合金AG-B12401制填料金属 线料 第P.pdf
  • ASD-STAN PREN 3954-2001 Aerospace Series Silver Base Alloy AG-B12401 Filler Metal for Brazing Powder or Paste (Edition P 2 Supersedes Edition P 1 January 1994 Replaced by EN 3954)《.pdf ASD-STAN PREN 3954-2001 Aerospace Series Silver Base Alloy AG-B12401 Filler Metal for Brazing Powder or Paste (Edition P 2 Supersedes Edition P 1 January 1994 Replaced by EN 3954)《.pdf
  • ASD-STAN PREN 3955-2001 Aerospace Series Silver Base Alloy AG-B12401 Filler Metal for Brazing Rolled Foil (Edition P 3 Supersedes Edition P 2 May 1995 )《航空航天系列 钎焊用银基合金AG-B12401填料金属.pdf ASD-STAN PREN 3955-2001 Aerospace Series Silver Base Alloy AG-B12401 Filler Metal for Brazing Rolled Foil (Edition P 3 Supersedes Edition P 2 May 1995 )《航空航天系列 钎焊用银基合金AG-B12401填料金属.pdf
  • ASD-STAN PREN 3956-2001 Aerospace Series Silver Base Alloy AG-B14001 Filler Metal for Brazing Wire (Edition P 3)《航空航天系列 钎焊用银基合金AG-B14001填料金属 线料 第P3版》.pdf ASD-STAN PREN 3956-2001 Aerospace Series Silver Base Alloy AG-B14001 Filler Metal for Brazing Wire (Edition P 3)《航空航天系列 钎焊用银基合金AG-B14001填料金属 线料 第P3版》.pdf
  • ASD-STAN PREN 3957-2001 Aerospace Series Silver Base Alloy AG-B14001 Filler Metal for Brazing Powder or Paste (Edition P 3 Supersedes Edition P 2 May 1995)《航空航天系列 钎焊用银基合金AG-B14001填.pdf ASD-STAN PREN 3957-2001 Aerospace Series Silver Base Alloy AG-B14001 Filler Metal for Brazing Powder or Paste (Edition P 3 Supersedes Edition P 2 May 1995)《航空航天系列 钎焊用银基合金AG-B14001填.pdf
  • ASD-STAN PREN 3958-2001 Aerospace Series Silver Base Alloy AG-B14001 Filler Metal for Brazing Rolled Foil (Edition P 3 Supersedes Edition P 2 May 1995 Replaced by EN 3958)《航空航天系列 钎.pdf ASD-STAN PREN 3958-2001 Aerospace Series Silver Base Alloy AG-B14001 Filler Metal for Brazing Rolled Foil (Edition P 3 Supersedes Edition P 2 May 1995 Replaced by EN 3958)《航空航天系列 钎.pdf
  • 相关搜索

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

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