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

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

1、国家三级(数据库技术)机试模拟试卷 94及答案与解析 一、程序设计题 1 已知数据文件 IN.DAT中存有 300个五位数,并已调用读函数 ReadDat()把这些数存入数组 a中,请编制一函数 jsValue(),其功能是:求出满足以下条件的数的个数 cnt、所有满足此条件的数的平均值 pjz1,以及不满足此条件的数的平均值pjz2,最后调用写函数把结果输出到 out.dat文件。 条件:将五位数的万位、百位、个位数字重组成一个三位数 a,将五位数的千位、十位数字重组成一个两位数 b,前一个数 a能被后一个数 b整除 。 例如: 24360满足条件 (230能被 46整除 ); 38129不

2、满足条件 (319不能被 82整除 )。 部分源程序已给出。 程序中已定义数组: a300,已定义变量: cnt、 pjz1、 pjz1。 请勿改动主函数 main()、读函数 ReadDat()和写函数 writeDat()的内容。 #include stdio.h int a300,cnt=0; double pjzl-0.0,pjz2=0.0; jsValue() main() int i; readDat(); jsValue(); writeDat(); printf (“cnt=%dn 满足条件的平均值 pzj1=%7.21 fn不满足条件的平均值 pjz2=%7.21fn“ ,c

3、nt,pjz1,pjz2); readDat ( ) FILE *fp; int i; fp=fopen(“ in.dar“ ,“ r“); for(i=0,i 300;i+) fscanf(fp,“%d“ , fclose(fp); writeDat() FILE *fp; int i; fp=fopen(“ out.dar“ ,“ w“ ); fprintf(fp,“ %dn%7.21fn%7.21fn“ ,cnt,pjz1,pjz2); fclose(fp); 国家三级(数据库技术)机试模拟试卷 94答案与解析 一、程序设计题 1 【正确答案】 jsValue() int i,g,s,b

4、,q,w,k=0,n1,n2; for(i=O;i 300;i+) /*取出各位数字 */ g=ai%10; s=ai%100/10; b=ai/100%10; q=ai/1000%10; w=ai/lO000; /*重组新数 */ n1=w*100+b*10+g; n2=q*10+s; /*判断条件 */ if(n1%n2=0) cet+;pjz1+-ai; else k+;pjz2+=ai; /*计算平均值 */ pjz1/=cnt; pjz2/=k; 【试题解析】 类型:数字统计,数字打散运算。 关键:取出一个数的各位数字,以及将各位数字重组成新的数。 ai%10对 10求余结 果为个位数, ai%100/10先对 100求余得出后两位数然后再除 10,由于为整数,因此得出后两位数的第一位。依此类推。

展开阅读全文
相关资源
猜你喜欢
  • ANSI INCITS ISO IEC 19763-1-2007 Information technology - Metamodel framework for interoperability (MFI) -- Part 1 Reference model《信息技术.互操作性用元模型框架(MFI).第1部分 参考模型》.pdf ANSI INCITS ISO IEC 19763-1-2007 Information technology - Metamodel framework for interoperability (MFI) -- Part 1 Reference model《信息技术.互操作性用元模型框架(MFI).第1部分 参考模型》.pdf
  • ANSI INCITS ISO IEC 19763-1-2007 Information technology Metamodel framework for interoperability (MFI) Part 1 Reference model.pdf ANSI INCITS ISO IEC 19763-1-2007 Information technology Metamodel framework for interoperability (MFI) Part 1 Reference model.pdf
  • ANSI INCITS ISO IEC 19763-3-2007 Information technology Metamodel framework for interoperability (MFI) Part 3 Metamodel for ontology registration.pdf ANSI INCITS ISO IEC 19763-3-2007 Information technology Metamodel framework for interoperability (MFI) Part 3 Metamodel for ontology registration.pdf
  • ANSI INCITS ISO IEC 19778-2-2008 Information technology - Learning education and training - Collaborative technology - Collaborative workplace - Part 2 Collaborative environment da.pdf ANSI INCITS ISO IEC 19778-2-2008 Information technology - Learning education and training - Collaborative technology - Collaborative workplace - Part 2 Collaborative environment da.pdf
  • ANSI INCITS ISO IEC 19778-3-2008 Information technology - Learning education and training - Collaborative technology - Collaborative workplace - Part 3 Collaborative group data mod.pdf ANSI INCITS ISO IEC 19778-3-2008 Information technology - Learning education and training - Collaborative technology - Collaborative workplace - Part 3 Collaborative group data mod.pdf
  • ANSI INCITS ISO IEC 19784-1 AMD 1-2007 Information technology BioAPI Biometric Application Programming Interface Part 1 BioAPI Specification AMENDMENT 1 BioGUI specification.pdf ANSI INCITS ISO IEC 19784-1 AMD 1-2007 Information technology BioAPI Biometric Application Programming Interface Part 1 BioAPI Specification AMENDMENT 1 BioGUI specification.pdf
  • ANSI INCITS ISO IEC 19784-1 AMD 3-2010 Information technology - Biometric application programming interface - Part 1 BioAPI specification AMD 3 Support for interchange of certifica.pdf ANSI INCITS ISO IEC 19784-1 AMD 3-2010 Information technology - Biometric application programming interface - Part 1 BioAPI specification AMD 3 Support for interchange of certifica.pdf
  • ANSI INCITS ISO IEC 19784-1-2006 Information technology - Biometric application programming interface - Part 1 BioAPI specification《信息技术.生物统计应用程序设计接口.第1部分 BioAPI规范》.pdf ANSI INCITS ISO IEC 19784-1-2006 Information technology - Biometric application programming interface - Part 1 BioAPI specification《信息技术.生物统计应用程序设计接口.第1部分 BioAPI规范》.pdf
  • ANSI INCITS ISO IEC 19784-1-2006 Information technology Biometric application programming interface Part 1 BioAPI specification.pdf ANSI INCITS ISO IEC 19784-1-2006 Information technology Biometric application programming interface Part 1 BioAPI specification.pdf
  • 相关搜索

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

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