【计算机类职业资格】三级网络技术机试-177及答案解析.doc

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

1、三级网络技术机试-177 及答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.请编制程序,要求:将文件 IN92.DAT中的 200个整数读入数组 xx中,求出数组 xx中最大数 max及最大数的个数 cnt和数组 xx中值能被 3整除或能被 7整除的数的算术平均值 pj(保留两位小数),结果max,cnt,pj 输出到 out92.dat中。部分程序、读函数 read_dat(int xx200)及输出格式已给出。试题程序:#includeconio.h#includestdio.h#define N 200void read_dat(int

2、 xxN)int i,j;FILE *fp;fp=fopen(“IN92.DAT“,“r“);for(i=0;i20;i+)for(j=0;j10;j+fscanf(fp,“%d,“,printf (“%d“, xx i*10+j);printf (“/n“);fclose (fp);void main()int i, k, cnt, xx N,max;float pj;FILE *fw;long j=0;clrscr ();fw=fopen (“out92.dat“, “w“);read_dat (xx);printf (“/n/nmax=%d, cnt=%d, pj=%6.2f/n“, m

3、ax, cnt,pj);fprintf(fw, “%d/n%d/n%6.2f/n“,max, cnt,pj);fclose (fw);(分数:100.00)_三级网络技术机试-177 答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.请编制程序,要求:将文件 IN92.DAT中的 200个整数读入数组 xx中,求出数组 xx中最大数 max及最大数的个数 cnt和数组 xx中值能被 3整除或能被 7整除的数的算术平均值 pj(保留两位小数),结果max,cnt,pj 输出到 out92.dat中。部分程序、读函数 read_dat(int xx

4、200)及输出格式已给出。试题程序:#includeconio.h#includestdio.h#define N 200void read_dat(int xxN)int i,j;FILE *fp;fp=fopen(“IN92.DAT“,“r“);for(i=0;i20;i+)for(j=0;j10;j+fscanf(fp,“%d,“,printf (“%d“, xx i*10+j);printf (“/n“);fclose (fp);void main()int i, k, cnt, xx N,max;float pj;FILE *fw;long j=0;clrscr ();fw=fope

5、n (“out92.dat“, “w“);read_dat (xx);printf (“/n/nmax=%d, cnt=%d, pj=%6.2f/n“, max, cnt,pj);fprintf(fw, “%d/n%d/n%6.2f/n“,max, cnt,pj);fclose (fw);(分数:100.00)_正确答案:(void main()int i,k,cnt,xxN,max;float pj;FILE *fw;long j=0;clrscr();fw=fopen(“out92.dat“,“N“);read_dat(xx);max=xx0;for(i=1,k=0;iN;i+)if(xx

6、imax)max=xxi; /*求出数组 xx中最大数 max*/if(xxi%3= =0 |xxi%7= =0)j+=xxi; /*求出数组 xx中值能被 3整除或能被 7整除的数的总和*/k+;for(i=0,cnt=0;iN;i+)if(xxi= =max)cnt+; /*求出数组 xx中最大数 max的个数*/Pj=(float)(j*100/k)/100;/*求出数组 xx中值能被 3整除或能被 7整除的数的平均值*/printf(“/n/nmax=%d,cnt=%d,pj=%6.2f/n“,max,cnt,pj);fprintf(fw,“%d/n%d/n%6.2f/n“,max,c

7、nt,pj);fclose(fw);)解析:解析 本题考查的知识点如下:(1)运算符“%”的使用。(2)判断结构中多个条件的布尔运算。首先,要找出数组中最大的元素。先定义第 1个元素为最大的元素,然后依次和后面的元素比较,若后面的数中有大于第 1个元素的,则将这个数定义为最大的元素。再和后面的数进行比较。一个数 a除以 b取余所得的数为 0,则 a能被 b整除。根据题意可知,被 3整除和被 7整除两个条件满足一个即可,所以两个条件之间用“或”运算。在本题中,要求算术平均值保留两位小数。使用的方法是:将和乘以 100除以个数强制类型转换后再除以 100。为了保证和有效,我们定义了一个长整型变量来记录和。因为个数也为整型,运算符“/”在这里的含义是整除,而我们要保留小数,所以要使用强制类型转换将和乘以 100的结果转换为浮点类型,这样就可以实现保留两位小数。

展开阅读全文
相关资源
猜你喜欢
  • EN 24566-1989 en Shipbuilding Yachting Ships Marine Propellers Propeller Shafts Hubs Dimensions《造船工业 舱内安装发动机的游览船 螺旋桨轴端和轴壳(ISO 4566-85)》.pdf EN 24566-1989 en Shipbuilding Yachting Ships Marine Propellers Propeller Shafts Hubs Dimensions《造船工业 舱内安装发动机的游览船 螺旋桨轴端和轴壳(ISO 4566-85)》.pdf
  • EN 24829 PART 1-1990 en CORRIGENDUM Steel and Cast Iron - Determination of Total Silicon Content - Reduced Molybdosilicate Spectrophotometric Method - Part 1 Silicon Content Betwee.pdf EN 24829 PART 1-1990 en CORRIGENDUM Steel and Cast Iron - Determination of Total Silicon Content - Reduced Molybdosilicate Spectrophotometric Method - Part 1 Silicon Content Betwee.pdf
  • EN 24829 PART 2-1990 CORRIGENDUM Steel and Cast Iron - Determination of Total Silicon Content - Reduced Molybdosilicate Spectrophotometric Method - Part 2 Silicon Content Between 0.pdf EN 24829 PART 2-1990 CORRIGENDUM Steel and Cast Iron - Determination of Total Silicon Content - Reduced Molybdosilicate Spectrophotometric Method - Part 2 Silicon Content Between 0.pdf
  • EN 24829-1-1990 Steel and cast iron determination of total silicon content reduced molybdosilicate spectrophotometric method part 1 silicon content between 0 05 and 1 %《钢和铸铁 硅总含量的测.pdf EN 24829-1-1990 Steel and cast iron determination of total silicon content reduced molybdosilicate spectrophotometric method part 1 silicon content between 0 05 and 1 %《钢和铸铁 硅总含量的测.pdf
  • EN 24869-1-1992 en Acoustics - Hearing Protectors - Subjective Method for the Measurement of Sound Attenuation《声学 听力保护器 主观法测量声衰减》.pdf EN 24869-1-1992 en Acoustics - Hearing Protectors - Subjective Method for the Measurement of Sound Attenuation《声学 听力保护器 主观法测量声衰减》.pdf
  • EN 24883-1993 en Hardmetals - Determination of Contents of Metallic Elements by X-Ray Fluorescence - Solution Method《硬质合金 用X射线荧光测定金属元素的含量 溶液法(ISO 4883-1978)》.pdf EN 24883-1993 en Hardmetals - Determination of Contents of Metallic Elements by X-Ray Fluorescence - Solution Method《硬质合金 用X射线荧光测定金属元素的含量 溶液法(ISO 4883-1978)》.pdf
  • EN 24884-1993 en Hardmetals - Sampling and Testing of Powders Using Sintered Test Pieces《硬质合金 用烧结试块的粉末取样和试验(ISO 4884-1978)》.pdf EN 24884-1993 en Hardmetals - Sampling and Testing of Powders Using Sintered Test Pieces《硬质合金 用烧结试块的粉末取样和试验(ISO 4884-1978)》.pdf
  • EN 24937-1990 en Steel and Iron - Determination of Chromium Content - Potentiometric or Visual Method《钢和铸铁 铬含量的测定 电位滴定法或肉眼法》.pdf EN 24937-1990 en Steel and Iron - Determination of Chromium Content - Potentiometric or Visual Method《钢和铸铁 铬含量的测定 电位滴定法或肉眼法》.pdf
  • EN 24938-1990 Steel and Iron - Determination of Nickel Content - Gravimetric or Titrimetric Method《钢和铁 镍含量的测定 重量法或滴定法》.pdf EN 24938-1990 Steel and Iron - Determination of Nickel Content - Gravimetric or Titrimetric Method《钢和铁 镍含量的测定 重量法或滴定法》.pdf
  • 相关搜索

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

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