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

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

1、国家三级(数据库技术)机试模拟试卷 115及答案与解析 一、程序设计题 1 已知数据文件 IN.dat中存有 300个四位数,并已调用读函数 Rdata()把这些数存入数组 a中,请编写函数 NumCal(),其功能是:求出千位上的数加个位上的数等于百位上的数加十位上的数的四位数的个数 count,再求出所有满足此条件的四位数的平均值 Ave1,以及不满足此条件的四位数的平均值 Ave2。最后调用写函数Wdata(),把结果输出到 OUT.dat文件中。 例如: 6712, 6+2=7+1,则该数满足条件,计算平均值 Ave1,且个数count=count+1。 8129, 8+9!=1+2,

2、则该数不满足条件,计算平均值 Ave2。 注意:部分源程序已经给出。程序中已定义数组 a300,已定义变量 count、Ave1、 Ave2。请勿改动主函数 main()、读函数 Rdata()和写函数 Wdata()的内容。 #include stdio. h int a300, count = 0; double Ave1 = 0.0, Ave2 = 0.0; void NumCal () void Rdata() FILE *fp; int i; fp = fopen(“IN. dat“, “r“); for (i=0; i 300; i+) fscanf( fp, “%d,“, fcl

3、ose (fp); void Wdata () FILE *fp; fp = fopen(“OUT. dat“, “w“); fprintf(fp, “%dn%7.2fn%7.2fn“, count, Ave1, Ave2); fclose (fp); main () Rdata (); NumCal ( ); Wdata (); printf (“count=%dn 满足条件的平均值 Ave1=%7.2fn 不满足条件的平均值Ave2=%7.2fn“, count, Ave1, Ave2); 国家三级(数据库技术)机试模拟试卷 115答案与解析 一、程序设计题 1 【正确答案】 void N

4、umCal() int i, n = 0, thou, hun, ten, data; for (i=0; i 300; i+) thou = ai/1000; hun = ai%1000/100; ten = ai%100/10; data = ai%10; if (thou+ data = hun+ ten) count+; Ave1 += ai; else n+; Ave2 += ai; Ave1 /= count; Ave2 /= n; 解题思路 对于每一个四位数,用这个四位数除以 1000,可得到这个四位数千位上的数字输给变量 thou;这个四位数对 1000求余数然后再除以 100

5、可得到这个四位数百位上的数字输给变量 hun;这个四位数对 100求余数然后再除以 10,可得到这个四位数十位上的数字输给变量 ten;这个四位数对 10求余数,可得到这个四位数个位上的数字输给变量 data。 然后判断表达式 thou+ data =hun+ ten是否成立,如果成立,则计数变量 count加 1,同时把 这个数加到变量 Ave1上;否则计数变量 n加 1,同时把这个数加到变量 Ave2上。循环结束后,变量 Ave1的值除以 count,就得到所有满足此条件的四位数的平均值 Ave1;变量 Ave2的值除以 n,就得到有不满足此条件的四位数的平均值 Ave2。 【知识模块】 三级数据库技术机试模拟

展开阅读全文
相关资源
猜你喜欢
  • STAS SR ISO 1776-1995 Glass — Resistance to attack by hydrochloric acid at 100°C Flame emission or flame atomic absorption spectrometric method《玻璃.在100°C抗攻击盐酸.火焰发射或火焰原子吸收光谱法. 》.pdf STAS SR ISO 1776-1995 Glass — Resistance to attack by hydrochloric acid at 100°C Flame emission or flame atomic absorption spectrometric method《玻璃.在100°C抗攻击盐酸.火焰发射或火焰原子吸收光谱法. 》.pdf
  • STAS SR ISO 1784-1995 Aluminium alloys Determination of zinc EDTA titrimetric method《铝合金.锌的测定.乙二胺四乙酸滴定法》.pdf STAS SR ISO 1784-1995 Aluminium alloys Determination of zinc EDTA titrimetric method《铝合金.锌的测定.乙二胺四乙酸滴定法》.pdf
  • STAS SR ISO 1795-1995 Rubber raw natural and synthetic material - Sampling and further preparative procedures《橡胶,原材料,自然和合成材料.取样和进一步制备程序 》.pdf STAS SR ISO 1795-1995 Rubber raw natural and synthetic material - Sampling and further preparative procedures《橡胶,原材料,自然和合成材料.取样和进一步制备程序 》.pdf
  • STAS SR ISO 1797-1-1992 Dental rotary instrumente - Shahks Part 1  Shanks made of metals《牙科旋转仪.柄第1部分:金属制把柄》.pdf STAS SR ISO 1797-1-1992 Dental rotary instrumente - Shahks Part 1 Shanks made of metals《牙科旋转仪.柄第1部分:金属制把柄》.pdf
  • STAS SR ISO 1797-2-1992 Dental rotary instruments - Shanks Part 2  Shanks made of plastics《牙科旋转器械.把柄第二部:塑料制把柄》.pdf STAS SR ISO 1797-2-1992 Dental rotary instruments - Shanks Part 2 Shanks made of plastics《牙科旋转器械.把柄第二部:塑料制把柄》.pdf
  • STAS SR ISO 1798-1983 Polymeric materials cellular flexible Determination of tensiie strength and elongation at break.《高聚物多孔材料.张力强度和断裂延伸率的测定》.pdf STAS SR ISO 1798-1983 Polymeric materials cellular flexible Determination of tensiie strength and elongation at break.《高聚物多孔材料.张力强度和断裂延伸率的测定》.pdf
  • STAS SR ISO 1807-1995 Continuous mechanica! handling equipment for loose bulk materials - Oscillating conveyors and shaking or reciprocating feeders with rectangular or trapezoidal.pdf STAS SR ISO 1807-1995 Continuous mechanica! handling equipment for loose bulk materials - Oscillating conveyors and shaking or reciprocating feeders with rectangular or trapezoidal.pdf
  • STAS SR ISO 1815-1995 Continuous mechanical handling equipment for Ioose bulk materials -Vibrating feeders and conveyors《大量松散材料的连续机械装卸设备.振动供料机和传送带 》.pdf STAS SR ISO 1815-1995 Continuous mechanical handling equipment for Ioose bulk materials -Vibrating feeders and conveyors《大量松散材料的连续机械装卸设备.振动供料机和传送带 》.pdf
  • STAS SR ISO 1816-1995 Continuous mechanical handling equipment for loose bulk materials and unit loads - Belt conveyors - Basic characteristics of motorized driving pulleys《大型松散材料和.pdf STAS SR ISO 1816-1995 Continuous mechanical handling equipment for loose bulk materials and unit loads - Belt conveyors - Basic characteristics of motorized driving pulleys《大型松散材料和.pdf
  • 相关搜索

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

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