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

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

1、国家二级 C语言机试(操作题)模拟试卷 55及答案与解析 一、程序填空题 1 给定程序中,函数 fun的功能是:计算形参 x所指数组中 N个数的平均值 (规定所有数均为正数 ),作为函数值返回;并将大于平均值的数放在形参 Y所指数组中,在主函数中输出。 例如,有 10个正数: 46 30 32 40 6 17 45 15 48 26,平均值为: 30 500000 主函数中输出: 46 32 40 45 48 请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。 注意:源程序存放 在考生文件夹下的 BLANKl C中。 不得增行或删行,也不得更改程序的结构 ! #includ

2、e #include #define N 10 double fun(double x, double *y) int i, j; double av; /*found*/ av=_1_; /*found*/ for(2=0; iaV)y_3_=xi; yj=一 1; return av; main() int i; double xN, yN; for(i=0; i=0; i+)printf (“ 5 1f”, yi); printf(“ n”); 二、程序修改题 2 给定程序 MODll C中函数 fun的功能是:将 S所指字符串中的字母转换为按字母序列的后续字母 (但 Z转换为 A, Z

3、转换为 a),其他字符不变。 请改正函数 fun中指定部位的错误,使它能得出正确的结果。 注意:不要改动 main函数,不得增行或删行,也不得更改程序的结构 ! #include #include VOid fun(char *s) /*found*/ while(*s!=) if(*s=A *s=a *sj成绩构成, N名学生的数据已存入结构体数组 a中。请编写函数 fun,函数的功能是:找出成绩最高的学生记录,通过 形参指针传回主函数 (规定只有一个最高分 )。已给出函数的首部,请完成该函数。 注意:部分源程序存在文件 PROGl C中。 请勿改动主函数 main和其他函数中的任何内容,仅

4、在函数 fun的花括号中填入你编写的若干语句。 #include #include #define N 10 typedef struct ss char num10; int s; STU; fun(STU a, STU *s) main() STU aN=“A01”, 81), “A02”, 89, “A03”, 66), “A04”, 87), “A05”,77, “A06”, 90, “A07”, 79, “A08”, 61, “A09”, 80, “A10”, 71),m ; int i; printf (“*The original data * n”); for(i=0; iav

5、)y_3_=xi; ”是将 xi保存在 y所指的数 组中, i是循环变量, j初始化为 0,故 y的计数变量为 j,故第三空处应为 “i+”。 二、程序修改题 2 【正确答案】 (1)while(*s) 或 while(*s!= 0) 或 while (*s!=0) (2)s+; 【试题解析】 函数的功能是将字符串中的字母改为该字母序列的后续字母。 (1)第一个错误标识下的 “while(*s!=)”语句原意是 s不指向字符串尾就进入下而的循环,所以对于指针判断不为尾符的语句应该是 “while(*s)”或者“while(*s!= 0)”或者 “while(*s!=0)”。 (2)第二个标识下 “(*s)+; ”是对字符内容加 1,而原题是对字符位置加 1,所以将其改为 “s+; ”。 三、程序设计题 3 【正确答案】 int i, max=a0 s, j=0; for(i=1; iN; i+) if(maxai s) j=i; max=ai s; *s=aj; 【试题解析】 该程序功能是求最高分数的学生。本题是关于求解结构体中某些成员的最大值,首先将第一个值设 定为最大值,并在循环中将其他所有值与该值进行比较,求得最大值。然后将最大值与所有值进行比较,求得所有的最大值。

展开阅读全文
相关资源
猜你喜欢
  • BS ISO IEC 33004-2015 Information technology Process assessment Requirements for process reference process assessment and maturity models《信息技术 过程评定 过程参考 过程评定和成熟度模型要求》.pdf BS ISO IEC 33004-2015 Information technology Process assessment Requirements for process reference process assessment and maturity models《信息技术 过程评定 过程参考 过程评定和成熟度模型要求》.pdf
  • BS ISO IEC 33020-2015 Information technology Process assessment Process measurement framework for assessment of process capability《信息技术 过程评定 过程评定能力的过程衡量架构》.pdf BS ISO IEC 33020-2015 Information technology Process assessment Process measurement framework for assessment of process capability《信息技术 过程评定 过程评定能力的过程衡量架构》.pdf
  • BS ISO IEC 33063-2015 Information technology Process assessment Process assessment model for software testing《信息技术 过程评估 软件测试过程评估模型》.pdf BS ISO IEC 33063-2015 Information technology Process assessment Process assessment model for software testing《信息技术 过程评估 软件测试过程评估模型》.pdf
  • BS ISO IEC 33071-2016 Information technology Process assessment An integrated process capability assessment model for Enterprise processes《信息技术 过程评定 企业流程的集成过程能力评估模型》.pdf BS ISO IEC 33071-2016 Information technology Process assessment An integrated process capability assessment model for Enterprise processes《信息技术 过程评定 企业流程的集成过程能力评估模型》.pdf
  • BS ISO IEC 3788-1990 Information processing - 9-track 12 7 mm (0 5 in) wide magnetic tape for information interchange using phase encoding at 126 ftpmm (3200 ftpi) - 63 cp.pdf BS ISO IEC 3788-1990 Information processing - 9-track 12 7 mm (0 5 in) wide magnetic tape for information interchange using phase encoding at 126 ftpmm (3200 ftpi) - 63 cp.pdf
  • BS ISO IEC 38500-2015 Information technology Governance of IT for the organization《信息技术 组织的IT治理》.pdf BS ISO IEC 38500-2015 Information technology Governance of IT for the organization《信息技术 组织的IT治理》.pdf
  • BS ISO IEC 38505-1-2017 Information technology Governance of IT Governance of data Application of ISO IEC 38500 to the governance of data《信息技术 IT规制 数据治理 ISO IEC 38500数据治理应.pdf BS ISO IEC 38505-1-2017 Information technology Governance of IT Governance of data Application of ISO IEC 38500 to the governance of data《信息技术 IT规制 数据治理 ISO IEC 38500数据治理应.pdf
  • BS ISO IEC 40314-2016 Information technology Mathematical Markup Language (MathML) Version 3 0 2nd Edition《信息技术 数学标记语言 (MathML) 版本3 0 第2版》.pdf BS ISO IEC 40314-2016 Information technology Mathematical Markup Language (MathML) Version 3 0 2nd Edition《信息技术 数学标记语言 (MathML) 版本3 0 第2版》.pdf
  • BS ISO IEC 4873-1992 Information technology - ISO 8-bit code for information interchange - Structure and rules for implementation《信息技术 信息交换用ISO 8位编码 实施的结构和准则》.pdf BS ISO IEC 4873-1992 Information technology - ISO 8-bit code for information interchange - Structure and rules for implementation《信息技术 信息交换用ISO 8位编码 实施的结构和准则》.pdf
  • 相关搜索

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

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