[计算机类试卷]国家三级(数据库技术)机试模拟试卷65及答案与解析.doc

上传人:eventdump275 文档编号:495341 上传时间:2018-11-28 格式:DOC 页数:3 大小:27.50KB
下载 相关 举报
[计算机类试卷]国家三级(数据库技术)机试模拟试卷65及答案与解析.doc_第1页
第1页 / 共3页
[计算机类试卷]国家三级(数据库技术)机试模拟试卷65及答案与解析.doc_第2页
第2页 / 共3页
[计算机类试卷]国家三级(数据库技术)机试模拟试卷65及答案与解析.doc_第3页
第3页 / 共3页
亲,该文档总共3页,全部预览完了,如果喜欢就下载吧!
资源描述

1、国家三级(数据库技术)机试模拟试卷 65及答案与解析 一、程序设计题 1 已知在文件 IN65.DAT中存有若干个 (个数 200)4位数字的正整数,函数ReadDat()是读取这若干个正整数并存入数组 xx中。请编制函数 CalValue(),其功能要求是: (1)求出这个文件中共有多少个正整数 totNum。 (2)求出这些数中的各位数字之和是奇数的个数 totCnt,以及满足此条件的这些数的算术平均值 totPjz。最后调用函数 WriteDat()把所有结果输出到文件 OUT65.DAT中。 注意:部分源程序已 给出。 请勿改动主函数 main()、读函数 ReadDat()和写函数

2、WriteDat()的内容。 试题程序: #include stdio.h #include conio.h #define MAXNUM 200 int xxMAXNUM; int totNum=0; int totCnt=0; double totPjz=0.0; int ReadDat(void); void WriteDat(void); void CalValue(void) void main() int i; clrscr(); for(i=0;i MAXNUM;i+) xxi=0; if (ReadDat () printf ( “数据文件 IN65.DAT不能打开 ! 007

3、n“); return; CalValue(); printf ( “文件 IN65.DAT中共有正整数 =%d个 n“, totNum); printf ( “符合条件的正整数的个数 =%d个 n“, totCnt); printf(“平均值 =%.21fn“,totPjz); WriteDat(); int ReadDat(void) FILE *fp; int i=0; if(fp=fopen(“IN65.DAT“,“r“)=NULL) return 1; while(!feof(fp) fscanf (fp, “%d“, return 0; void WriteDat(void) FI

4、LE *fp; fp=fopen(“OUT65.DAT“,“w“); fprintf(fp,“%dn%dn%.21fkn“,totNum, totCnt,totPjz); fclose(fp); 国家三级(数据库技术)机试模拟试卷 65答案与解析 一、程序设计题 1 【正确答案】 void CalValue(void) int i, thou, hun, ten, data; for(i=0; i MAXNUM; i+) if!xxi)break; if(xxi 0)totNum+; /*求正整数的个数 */ thou=xxi/1000; /*求四位数的千位数字 */ hun=xxi%1000

5、/100; /*求四位数的百位数字 */ ten=xxi%100/10; /*求四位数的十位数字 */ data=xxi%10; /*求四位数的个位数字 */ if(thou+hun+ten+data)%2) totCnt+; /*求各位数字之和是奇数的个数 */ totPjz+=xxi; /*求满足条件的数的总和 */ totPjz/=totCnt; /*求满足条件的数的平均值 */ 【试题解析】 本题考查的知识点如下; (1)“%” 与 “/”的使用。 (2)数组结束的判断和强行退出一层循环结构。 在本题中,并没有给出确切的数据个数,是以数据的最大个数定义的数组。在主函数中,给所有的数组成员赋初值为 0,而从文件中读取的数据是正整数,所以只要数组的某个元素为 0,则说明数组存的数据已经结束。此时就可以结束循环结构。这里要借助运算符 “%” 与 “/”将 4位数 的各位上的数拆成独立的数字,然后就可以根据题意要求判断。

展开阅读全文
相关资源
猜你喜欢
  • BS PD CLC TS 50131-2-11-2017 Alarm systems Intrusion and hold-up systems Intrusion detectors ALDDR《警报系统 入侵和滞留报警系统 入侵探测器 ALDDR》.pdf BS PD CLC TS 50131-2-11-2017 Alarm systems Intrusion and hold-up systems Intrusion detectors ALDDR《警报系统 入侵和滞留报警系统 入侵探测器 ALDDR》.pdf
  • BS PD CLC TS 50131-2-9-2016 Alarm systems Intrusion and hold-up systems Intrusion detectors Active infrared beam detectors《警报系统 入侵和滞留报警系统 入侵探测器 有源红外光束探测器》.pdf BS PD CLC TS 50131-2-9-2016 Alarm systems Intrusion and hold-up systems Intrusion detectors Active infrared beam detectors《警报系统 入侵和滞留报警系统 入侵探测器 有源红外光束探测器》.pdf
  • BS PD CLC TS 50131-9-2014 Alarm systems Intrusion and hold-up systems Alarm verification Methods and principles《警报系统 入侵和滞留警报系统 警报验证 方法和原则》.pdf BS PD CLC TS 50131-9-2014 Alarm systems Intrusion and hold-up systems Alarm verification Methods and principles《警报系统 入侵和滞留警报系统 警报验证 方法和原则》.pdf
  • BS PD CLC TS 50238-2-2015 Railway applications Compatibility between rolling stock and train detection systems Compatibility with track circuits《轨道交通 全部车辆和火车探测系统间的兼容性 轨道电路.pdf BS PD CLC TS 50238-2-2015 Railway applications Compatibility between rolling stock and train detection systems Compatibility with track circuits《轨道交通 全部车辆和火车探测系统间的兼容性 轨道电路.pdf
  • BS PD CLC TS 50459-1-2015 Railway applications Communication signalling and processing systems European Rail Traffic Management System Driver-Machine Interface General pri.pdf BS PD CLC TS 50459-1-2015 Railway applications Communication signalling and processing systems European Rail Traffic Management System Driver-Machine Interface General pri.pdf
  • BS PD CLC TS 50459-3-2016 Railway applications Communication signalling and processing systems European Rail Traffic Management System Driver-Machine Interface Ergonomic a.pdf BS PD CLC TS 50459-3-2016 Railway applications Communication signalling and processing systems European Rail Traffic Management System Driver-Machine Interface Ergonomic a.pdf
  • BS PD CLC TS 50568-4-2015 Electricity metering data exchange Lower layer PLC profile using SMITP B-PSK modulation《电力计量数据交换 采用SMITP B-PSK调制的低层PLC配置文件》.pdf BS PD CLC TS 50568-4-2015 Electricity metering data exchange Lower layer PLC profile using SMITP B-PSK modulation《电力计量数据交换 采用SMITP B-PSK调制的低层PLC配置文件》.pdf
  • BS PD CLC TS 50568-8-2015 Electricity metering data exchange The DLMS COSEM suite SMITP B-PSK PLC communication profile for neighbourhood networks Including The Original-.pdf BS PD CLC TS 50568-8-2015 Electricity metering data exchange The DLMS COSEM suite SMITP B-PSK PLC communication profile for neighbourhood networks Including The Original-.pdf
  • BS PD CLC TS 50574-2-2014 Collection logistics & treatment requirements for end-of-life household appliances containing volatile fluorocarbons or volatile hydrocarbons Spe.pdf BS PD CLC TS 50574-2-2014 Collection logistics & treatment requirements for end-of-life household appliances containing volatile fluorocarbons or volatile hydrocarbons Spe.pdf
  • 相关搜索

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

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