【计算机类职业资格】三级数据库技术机试-55及答案解析.doc

上传人:jobexamine331 文档编号:1321368 上传时间:2019-10-17 格式:DOC 页数:3 大小:28KB
下载 相关 举报
【计算机类职业资格】三级数据库技术机试-55及答案解析.doc_第1页
第1页 / 共3页
【计算机类职业资格】三级数据库技术机试-55及答案解析.doc_第2页
第2页 / 共3页
【计算机类职业资格】三级数据库技术机试-55及答案解析.doc_第3页
第3页 / 共3页
亲,该文档总共3页,全部预览完了,如果喜欢就下载吧!
资源描述

1、三级数据库技术机试-55 及答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.请编制程序,要求:将文件 IN91DAT 中的 200 个整数读入数组 xx 中,求出数组 xx 中奇数的个数cnt1 和偶数的个数 cnt2,以及数组 xx 下标为偶数的元素值的算术平均值 pj(保留 2 位小数),结果cnt1,cnt2,由输出到 out91.dat 中。 部分程序、读函数 read_dat(int xx200)及输出格式已给出。试题程序:#includeconioh#includestdioh#define N 200void realdat(i

2、nt xxN)int i:j;FILE*fp;fp:fopen(“IN91.DAT“,“r“);for(i=0;i20;i+)for(j=0;j10;j+)fscanf (fp, “%d, “,printf(“%d“,xxi*10+j);printf(“/n“);fclose(fp);void main(int cnt1,cnt2,xxN;float pj;FILE *fw;int i,k=0;long j;clrscr();fw=fopen(“out91.dat“,“w“);read_dat(xx);printf(“/n/ncntl=%d, cnt2=%d,pj=%6.2f/n“,cnt1,

3、cnt2,pj);fprintf(fw,“%d/n%d/n%6.2f/n“,cntl,cnt2,pj);fclose(fw);(分数:100.00)_三级数据库技术机试-55 答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.请编制程序,要求:将文件 IN91DAT 中的 200 个整数读入数组 xx 中,求出数组 xx 中奇数的个数cnt1 和偶数的个数 cnt2,以及数组 xx 下标为偶数的元素值的算术平均值 pj(保留 2 位小数),结果cnt1,cnt2,由输出到 out91.dat 中。 部分程序、读函数 read_dat(int x

4、x200)及输出格式已给出。试题程序:#includeconioh#includestdioh#define N 200void realdat(int xxN)int i:j;FILE*fp;fp:fopen(“IN91.DAT“,“r“);for(i=0;i20;i+)for(j=0;j10;j+)fscanf (fp, “%d, “,printf(“%d“,xxi*10+j);printf(“/n“);fclose(fp);void main(int cnt1,cnt2,xxN;float pj;FILE *fw;int i,k=0;long j;clrscr();fw=fopen(“o

5、ut91.dat“,“w“);read_dat(xx);printf(“/n/ncntl=%d, cnt2=%d,pj=%6.2f/n“,cnt1,cnt2,pj);fprintf(fw,“%d/n%d/n%6.2f/n“,cntl,cnt2,pj);fclose(fw);(分数:100.00)_正确答案:(void main()int cnt1,cnt2,xxN;float pj;FILE *fw;int i,k=0;long j;clrscr();fw=fopen(“out91.dat“,“w“);read_dat(xx);for(i=0,j=0,cnt1=0,cnt2=0;iN;i+)i

6、f (xxi%2) /*求出数组 xx 中奇数的个数 cnt1*/cnt1+;elsecnt2+; /*求出数组 xx 中偶数的个数 cnt2*/if (i%2=0)j+=xxi; /*求数组 xx 下标为偶数的元素值的总和*/k+;pj= (float) (j*100/k) /100; /*求数组 xx 下标为偶数的元素值的算术平均值 pj*/printf(“/n/ncnt1=%d, cnt2=%d,pj=%6.2f/n“,cnt1,cnt2,pj);fprintf(fw,“%d/n%d/n%6.2fkn“,cnt1,cnt2,pj);fclose(fw);)解析:解析 本题考查的知识点如下:(1)运算符“%”的使用。(2)强制类型转换和小数位数的保留。一个数除以 2 取余所得的数为 1,则它是奇数,否则是偶数,取余使用运算符“%”。在本题中,要求算术平均值保留两位小数。使用的方法是:将和乘以 100 除以个数强制类型转换后再除以 100。为了保证和有效,我们定义一个长整型变量来记录和。因为个数也为整型,运算符“/”在这里的含义是整除,而我们要保留小数,所以要使用强制类型转换将和乘以 100 的结果转换为浮点类型,这样就可以实现保留两位小数。使用循环对所有数据进行访问。

展开阅读全文
相关资源
猜你喜欢
  • EN 14630-2006 en Products and systems for the protection and repair of concrete structures - Test methods - Determination of carbonation depth in hardened concrete by the phenolpha.pdf EN 14630-2006 en Products and systems for the protection and repair of concrete structures - Test methods - Determination of carbonation depth in hardened concrete by the phenolpha.pdf
  • EN 14635-2010 en Glass packaging - 26 H 126 crown finish - Dimensions《玻璃包装 26 H 126冠形盖瓶口 尺寸》.pdf EN 14635-2010 en Glass packaging - 26 H 126 crown finish - Dimensions《玻璃包装 26 H 126冠形盖瓶口 尺寸》.pdf
  • EN 14636-1-2009 en Plastics piping systems for non-pressure drainage and sewerage - Polyester resin concrete (PRC) - Part 1 Pipes and fittings with flexible joints《无压地下排水和污水塑料管道系统 .pdf EN 14636-1-2009 en Plastics piping systems for non-pressure drainage and sewerage - Polyester resin concrete (PRC) - Part 1 Pipes and fittings with flexible joints《无压地下排水和污水塑料管道系统 .pdf
  • EN 14636-2-2009 en Plastics piping systems for non-pressure drainage and sewerage - Polyester resin concrete (PRC) - Part 2 Manholes and inspection chambers《无压排水和排污用塑料管道系统 聚酯树脂混凝土(.pdf EN 14636-2-2009 en Plastics piping systems for non-pressure drainage and sewerage - Polyester resin concrete (PRC) - Part 2 Manholes and inspection chambers《无压排水和排污用塑料管道系统 聚酯树脂混凝土(.pdf
  • EN 14637-2007 en Building hardware - Electrically controlled hold-open systems for fire smoke door assemblies - Requirements test methods application and maintenance《建筑五金件 防火门 防烟门组.pdf EN 14637-2007 en Building hardware - Electrically controlled hold-open systems for fire smoke door assemblies - Requirements test methods application and maintenance《建筑五金件 防火门 防烟门组.pdf
  • EN 14638-1-2006 en Transportable gas cylinders - Refillable welded receptacles of a capacity not exceeding 150 litres - Part 1 Welded austenitic stainless steel cylinders made to a.pdf EN 14638-1-2006 en Transportable gas cylinders - Refillable welded receptacles of a capacity not exceeding 150 litres - Part 1 Welded austenitic stainless steel cylinders made to a.pdf
  • EN 14638-3-2010 en Transportable gas cylinders - Refillable welded receptacles of a capacity not exceeding 150 litres - Part 3 Welded carbon steel cylinders made to a design justif.pdf EN 14638-3-2010 en Transportable gas cylinders - Refillable welded receptacles of a capacity not exceeding 150 litres - Part 3 Welded carbon steel cylinders made to a design justif.pdf
  • EN 14639-2005 en Crude tar and crude benzole - Characteristics and test methods《原焦油和原苯 特性和试验方法》.pdf EN 14639-2005 en Crude tar and crude benzole - Characteristics and test methods《原焦油和原苯 特性和试验方法》.pdf
  • EN 14647-2005 en Calcium aluminate cement Composition specifications and conformity criteria《铝酸钙水泥 成分 规范和一致性标准》.pdf EN 14647-2005 en Calcium aluminate cement Composition specifications and conformity criteria《铝酸钙水泥 成分 规范和一致性标准》.pdf
  • 相关搜索

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

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