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

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

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

2、dar (int xx N )int i,j;FILE *fp;fp=fopen(“IN94.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;clrscr();fw=fopen(“out94.dat“,“w“);read_dat(xx);printf(“/n/ncnt1=%d, cnt2=%d,pj=%6.2f/n“,cnt1,cnt2,pj);f

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

4、格式已给出。试题程序:#includeconio:h#includestdio.h#define N 200void read_dar (int xx N )int i,j;FILE *fp;fp=fopen(“IN94.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;clrscr();fw=fopen(“out94.dat“,“w“);read_

5、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=0;cnt1=0;cnt2=0;pi=0.0;clrscr();fw=fopen(“out94.dat“,“w“);read_dat(xx);for(i=0;iN;i+)if(xxi%2)cnt1+;

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

展开阅读全文
相关资源
猜你喜欢
  • BS ISO IEC 27033-5-2013 Information technology Security techniques Network security Securing communications across networks using Virtual Private Networks (VPNs)《信息技术 安全技术 网络安全 使用虚.pdf BS ISO IEC 27033-5-2013 Information technology Security techniques Network security Securing communications across networks using Virtual Private Networks (VPNs)《信息技术 安全技术 网络安全 使用虚.pdf
  • BS ISO IEC 27035-2-2016 Information technology Security techniques Information security incident management Guidelines to plan and prepare for incident response《信息技术 安全技术 信息安全事件管理 .pdf BS ISO IEC 27035-2-2016 Information technology Security techniques Information security incident management Guidelines to plan and prepare for incident response《信息技术 安全技术 信息安全事件管理 .pdf
  • BS ISO IEC 27036-3-2013 Information technology Security techniques Information security for supplier relationships Guidelines for information and communication technology supply ch.pdf BS ISO IEC 27036-3-2013 Information technology Security techniques Information security for supplier relationships Guidelines for information and communication technology supply ch.pdf
  • BS ISO IEC 27036-4-2016 Information technology Security techniques Information security for supplier relationships Guidelines for security of cloud services《信息技术 安全技术 供应商关系的信息安全 云服.pdf BS ISO IEC 27036-4-2016 Information technology Security techniques Information security for supplier relationships Guidelines for security of cloud services《信息技术 安全技术 供应商关系的信息安全 云服.pdf
  • BS ISO IEC 27038-2014 Information technology Security techniques Specification for digital redaction《信息技术 安全技术 数字编辑规范》.pdf BS ISO IEC 27038-2014 Information technology Security techniques Specification for digital redaction《信息技术 安全技术 数字编辑规范》.pdf
  • BS ISO IEC 27039-2015 Information technology Security techniques Selection deployment and operations of intrusion detection systems (IDPS)《信息技术 安全技术 入侵式检测系统的选择、开发和操作(IDPS)》.pdf BS ISO IEC 27039-2015 Information technology Security techniques Selection deployment and operations of intrusion detection systems (IDPS)《信息技术 安全技术 入侵式检测系统的选择、开发和操作(IDPS)》.pdf
  • BS ISO IEC 29102-2015 Information technology Office equipment Method for the determination of ink cartridge photo yield for colour printing with inkjet printers and multi-function .pdf BS ISO IEC 29102-2015 Information technology Office equipment Method for the determination of ink cartridge photo yield for colour printing with inkjet printers and multi-function .pdf
  • BS ISO IEC 29103-2011 Information technology Office equipment Colour photo test pages for measurement of ink cartridge yield for colour photo printing《信息技术 办公设备 用于测量印制彩色照片的墨盒的彩色照片试.pdf BS ISO IEC 29103-2011 Information technology Office equipment Colour photo test pages for measurement of ink cartridge yield for colour photo printing《信息技术 办公设备 用于测量印制彩色照片的墨盒的彩色照片试.pdf
  • BS ISO IEC 29109-1-2009 Information technology - Conformance testing methodology for biometric data interchange formats defined in ISO IEC 19794 Generalized conformance testing met.pdf BS ISO IEC 29109-1-2009 Information technology - Conformance testing methodology for biometric data interchange formats defined in ISO IEC 19794 Generalized conformance testing met.pdf
  • 相关搜索

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

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