【计算机类职业资格】三级信息管理技术机试-14及答案解析.doc

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

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

2、 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 pi;FILE *fw;int i,k=0:long j;clrscr();fw=fopen(“out91.dat“,“w“);read_dat(xx);printf(“/n/ncnt1=%d,cnt2=%d,pj=%6.2f/n“,cnt1,cnt2

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

4、已给出。试题程序:#includeconio.h#includestdio.h#define N 200void read_dat(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 pi;FILE *fw;int i,k=0:long j;clrscr();fw=fopen(“out91.dat

5、w“);read_dat(xx);printf(“/n/ncnt1=%d,cnt2=%d,pj=%6.2f/n“,cnt1,cnt2,pj);fprintf(fw,%d/n%d/n%6.2f/n“,cnt1,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+)if(xxi%2) /

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

展开阅读全文
相关资源
猜你喜欢
  • NF P98-216-2-1994 Test relating to pavements Measurement of the macrotexture Part 2  method for measuring without contact 《路面试验 宏观结构测定 第2部分 未接触的测量方法》.pdf NF P98-216-2-1994 Test relating to pavements Measurement of the macrotexture Part 2 method for measuring without contact 《路面试验 宏观结构测定 第2部分 未接触的测量方法》.pdf
  • NF P98-217-1-1995 Tests relating to pavements Tests relating to macrotexture Part 1  measurement of the surface drainage capacity 《路面试验 宏观结构测定 第1部分 地面排水能力测量》.pdf NF P98-217-1-1995 Tests relating to pavements Tests relating to macrotexture Part 1 measurement of the surface drainage capacity 《路面试验 宏观结构测定 第1部分 地面排水能力测量》.pdf
  • NF P98-218-3-1995 Tests relating to pavements Evenness tests Part 3  determination of longitudinal evennes indexes calculated from profilometer data 《路面试验 滑度试验 第3部分 通过表面光度仪数据计算纵向平滑.pdf NF P98-218-3-1995 Tests relating to pavements Evenness tests Part 3 determination of longitudinal evennes indexes calculated from profilometer data 《路面试验 滑度试验 第3部分 通过表面光度仪数据计算纵向平滑.pdf
  • NF P98-219-1-1998 Tests relating to pavements Transversal evenness-related tests Part 1  measurement of the profile section of a roadway Definitions and classification 《路面试验 横向整体相关.pdf NF P98-219-1-1998 Tests relating to pavements Transversal evenness-related tests Part 1 measurement of the profile section of a roadway Definitions and classification 《路面试验 横向整体相关.pdf
  • NF P98-219-2-1999 Test relating to pavements Transversal eveness tests Part 2  continuous dynamic measurement of the profile section by materialisation of the intersection of a pla.pdf NF P98-219-2-1999 Test relating to pavements Transversal eveness tests Part 2 continuous dynamic measurement of the profile section by materialisation of the intersection of a pla.pdf
  • NF P98-219-3-1999 Test relating to pavements Transversal eveness tests Part 3  discontinuous dynamic measurement of the profile section 《路面试验 横向稳定性试验 第3部分 截面的非连续动态测量》.pdf NF P98-219-3-1999 Test relating to pavements Transversal eveness tests Part 3 discontinuous dynamic measurement of the profile section 《路面试验 横向稳定性试验 第3部分 截面的非连续动态测量》.pdf
  • NF P98-219-4-1996 Test relating to pavement Eveness test Part 4  continuous static measurement of a profile 《路面试验 滑度试验 第4部分 表面的连续静态测量》.pdf NF P98-219-4-1996 Test relating to pavement Eveness test Part 4 continuous static measurement of a profile 《路面试验 滑度试验 第4部分 表面的连续静态测量》.pdf
  • NF P98-219-5-1996 Test relating to pavement Eveness test Part 5  measurement of a deformation class by moving a 1 50 M rule 《与人行道有关的试验 平整试验 第5部分 通过一移动的A1 50M比例尺对变形级别的测量》.pdf NF P98-219-5-1996 Test relating to pavement Eveness test Part 5 measurement of a deformation class by moving a 1 50 M rule 《与人行道有关的试验 平整试验 第5部分 通过一移动的A1 50M比例尺对变形级别的测量》.pdf
  • NF P98-220-2-1994 Tests relating to pavements Skid test Part 2  method for obtaining the longitudinal skid resistance 《路面试验 滑动试验 第2部分 抗纵向滑动方法》.pdf NF P98-220-2-1994 Tests relating to pavements Skid test Part 2 method for obtaining the longitudinal skid resistance 《路面试验 滑动试验 第2部分 抗纵向滑动方法》.pdf
  • 相关搜索

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

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