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

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

1、国家二级( C语言)机试模拟试卷 197及答案与解析 一、程序填空题( 30分) 1 给定程序中,函数 fun的功能是:判定形参 a所指的 NN(规定 N为奇数 )的矩阵是否是 “幻方 ”,若是,函数返回值为 1: 不是,函数返回值为 0。 “幻方 ”的判定条件是:矩阵每行、每列、主对角线及反对角线上元素之和都相等。 例如,以下33的矩阵就是一个 “幻方 ”: 请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。 注意:源程序存放在考生文件夹下的BLANKl C中。 不得增行或删行,也不得更改程序的结构 !#include#define N 3int fun(int(*a)N

2、) int i, j, m1, m2, row, colum; m1=m2=0 ; for(i=0; i 二、程序修改题( 30分) 2 给定程序 MODll C中函数 fun的功能是:计算 n的 5次方的值 (规定 n的值大于2、小于 8),通过形参指针传回主函数;并计算该值的个位、十位、百位上数字之和作为函数值返回。 例如, 7的 5次方是 16807,其低 3位数的和值是 15。 请改正函数 fun中指定部位的错误,使它能得出正确的结果。 注意:不要改动 main函数,不得增行或删行,也不得更改程序的结构 ! #include #include int fun(int n, int*value) int d, s, i; *found* d=0; s=0; for(i=1; i=8); sum=fun(n, 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 */ 【试题解析】 ( 1)首先,通过循环求总分,然后求得平均分。 ( 2)在循环中,进行平均分与每个成绩进行比较,并将满足条件的数据存入数组及对其进行累加。

展开阅读全文
相关资源
猜你喜欢
  • ANSI ISO IEC 16448-2002 Information technology 120 mm DVD Read-only disk (Adopted by INCITS)《信息技术.INCITS采用120mm DVD只读光盘》.pdf ANSI ISO IEC 16448-2002 Information technology 120 mm DVD Read-only disk (Adopted by INCITS)《信息技术.INCITS采用120mm DVD只读光盘》.pdf
  • ANSI ISO IEC 16449-2002 Information technology 80 mm DVD Read-only disk (Adopted by INCITS)《信息技术.INCITS采用80mm DVD只读光盘》.pdf ANSI ISO IEC 16449-2002 Information technology 80 mm DVD Read-only disk (Adopted by INCITS)《信息技术.INCITS采用80mm DVD只读光盘》.pdf
  • ANSI ISO IEC 17024-2003 Conformity assessment General requirements for bodies operating certification of persons (First Edition)《一致性评估.人员认证机构的一般要求.第1版》.pdf ANSI ISO IEC 17024-2003 Conformity assessment General requirements for bodies operating certification of persons (First Edition)《一致性评估.人员认证机构的一般要求.第1版》.pdf
  • ANSI ISO IEC 18014-2-2002(R2008) Information technology — Security techniques — Time-stamping services — Part 2 Mechanisms producing independent tokens《信息技术.安全技术.计时打印机服务.第2部分 产生独立标.pdf ANSI ISO IEC 18014-2-2002(R2008) Information technology — Security techniques — Time-stamping services — Part 2 Mechanisms producing independent tokens《信息技术.安全技术.计时打印机服务.第2部分 产生独立标.pdf
  • ANSI ISO IEC 18093-1999 Information technology Data interchange on 130 mm optical disk cartridges of type WORM (Write Once Read Many) using irreversible effects Capacity 5 2 Gbytes.pdf ANSI ISO IEC 18093-1999 Information technology Data interchange on 130 mm optical disk cartridges of type WORM (Write Once Read Many) using irreversible effects Capacity 5 2 Gbytes.pdf
  • ANSI ISO IEC 19113-2002(R2008) Geographic information — Quality principles《地理信息.质量原则》.pdf ANSI ISO IEC 19113-2002(R2008) Geographic information — Quality principles《地理信息.质量原则》.pdf
  • ANSI ISO IEC 1989-2002(R2008) Information technology — Programming languages — COBOL《信息技术.程序设计语言.COBOL》.pdf ANSI ISO IEC 1989-2002(R2008) Information technology — Programming languages — COBOL《信息技术.程序设计语言.COBOL》.pdf
  • ANSI ISO IEC 20061-2001 Information technology 12 65 mm wide magnetic tape cassette for information interchange Helical scan recording DTF-2 (Adopted by INCITS)《信息技术.信息交换用12.65mm宽盒.pdf ANSI ISO IEC 20061-2001 Information technology 12 65 mm wide magnetic tape cassette for information interchange Helical scan recording DTF-2 (Adopted by INCITS)《信息技术.信息交换用12.65mm宽盒.pdf
  • ANSI ISO IEC 20062-2001 Information technology 8 mm wide magnetic tape cartridge for information interchange Helical scan recording VXA-1 format (Adopted by INCITS)《信息技术.信息交换用8mm宽盒.pdf ANSI ISO IEC 20062-2001 Information technology 8 mm wide magnetic tape cartridge for information interchange Helical scan recording VXA-1 format (Adopted by INCITS)《信息技术.信息交换用8mm宽盒.pdf
  • 相关搜索

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

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