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

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

1、三级信息管理技术机试-248 及答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.设有 n 个人坐一圈并按顺时针方向从 1 到 n 编号,从第 s 个人开始进行 1 到 m 的报数,报数到第 m 个人,此人出圈,再从他的下一个人重新开始从 1 到 m 报数,如此进行下去直到所有的人都出圈为止。先要求按出圈次序,每 10 个人为一组,给出这 n 个人的顺序表。请编制函数 Josegh()实现此功能并调用函数WriteDat()把编号按照出圈顺序输出到文件 OUT86.DAT 中。设 n=100,s=1,m=10 进行编程。注意:部分源程序已给出。

2、请勿改动主函数 main()和写函数 WriteDat()的内容。试题程序:#include stdio.h#define N 100#define S 1#define M 10int P100,n,s,m;void WriteDat(void);void Josegh(void)void main()m=M;n=N;s=S;Josegh();WriteDat();void WriteDat(void)int i;FILE * fp;fp=fopen(“OUT86.DAT“,“w“);for(i=N-1;i=0;i - -)printf(“% 4d“,pi);fprintf(fp,“% 4d

3、pi);if(i%10=0)Printf(“/n“);fprintf(fp,“/n“);fclose(fp);(分数:100.00)_三级信息管理技术机试-248 答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.设有 n 个人坐一圈并按顺时针方向从 1 到 n 编号,从第 s 个人开始进行 1 到 m 的报数,报数到第 m 个人,此人出圈,再从他的下一个人重新开始从 1 到 m 报数,如此进行下去直到所有的人都出圈为止。先要求按出圈次序,每 10 个人为一组,给出这 n 个人的顺序表。请编制函数 Josegh()实现此功能并调用函数Wri

4、teDat()把编号按照出圈顺序输出到文件 OUT86.DAT 中。设 n=100,s=1,m=10 进行编程。注意:部分源程序已给出。请勿改动主函数 main()和写函数 WriteDat()的内容。试题程序:#include stdio.h#define N 100#define S 1#define M 10int P100,n,s,m;void WriteDat(void);void Josegh(void)void main()m=M;n=N;s=S;Josegh();WriteDat();void WriteDat(void)int i;FILE * fp;fp=fopen(“OU

5、T86.DAT“,“w“);for(i=N-1;i=0;i - -)printf(“% 4d“,pi);fprintf(fp,“% 4d“,pi);if(i%10=0)Printf(“/n“);fprintf(fp,“/n“);fclose(fp);(分数:100.00)_正确答案:(void Josegh(void)int i,j; /*定义循环控制变量*/int s1,w; /*存储开始报数的人的编号*/s1=s; /*第一个报数的人的编号*/for(i=1;i=n;i + +) /*给 n 个人从 1 到 n 编号*/pi-1=i;for(i=n;i=2;i - -) /*当人数少于 2

6、 时,停止报数*/s1=(s1+m-1)%i; /*下一个开始报数的人的编号是(s1+m-1)%i*/if(s1=0) /*若 s1 为 0,则说明要开始报数的是最后一个人*/s1=i;w=ps1-1; /*将要出圈的人移至数组的最后*/for(j=s1;j=i-1;j + +)pj-1=pj;pi-1=w;)解析:解析 此题是著名的“约瑟夫环”问题。首先要将每个人的编号存入数组。因为每次是从 s1 开始报数的,若是直线队则下一个开始报数的人的编号是 s1+m-1,但这里要建立一个环,即最后一个人报完数后第一个人接着报数。所以这时下一个开始报数的人的编号是(s1+m-1)%i,i 是此时圈中的总人数。若所得的结果为 0,则说明要开始报数的是最后一个人。在此人前面的那个人就是要出圈的人,使用循环将要出圈的人移至数组的最后。开始时,总人数为 n,以后依次减 1,直到最后一个人出圈。

展开阅读全文
相关资源
猜你喜欢
  • DIN EN ISO 7759-2010 Anodizing of aluminium and its alloys - Measurement of reflectance characteristics of aluminium surfaces using a goniophotometer or an abridged goniophotometer.pdf DIN EN ISO 7759-2010 Anodizing of aluminium and its alloys - Measurement of reflectance characteristics of aluminium surfaces using a goniophotometer or an abridged goniophotometer.pdf
  • DIN EN ISO 7765-1-2004 Plastics film and sheeting - Determination of impact resistance by the free-falling dart method - Part 1 Staircase methods (ISO 7765-1 1988) German version E.pdf DIN EN ISO 7765-1-2004 Plastics film and sheeting - Determination of impact resistance by the free-falling dart method - Part 1 Staircase methods (ISO 7765-1 1988) German version E.pdf
  • DIN EN ISO 7779-2011 Acoustics - Measurement of airborne noise emitted by information technology and telecommunications equipment (ISO 7779 2010) German version EN ISO 7779 2010《声学.pdf DIN EN ISO 7779-2011 Acoustics - Measurement of airborne noise emitted by information technology and telecommunications equipment (ISO 7779 2010) German version EN ISO 7779 2010《声学.pdf
  • DIN EN ISO 7783-2012 Paints and varnishes - Determination of water-vapour transmission properties - Cup method (ISO 7783 2011) German version EN ISO 7783 2011《油漆和清漆 水蒸气传输性质的测定 杯量法(.pdf DIN EN ISO 7783-2012 Paints and varnishes - Determination of water-vapour transmission properties - Cup method (ISO 7783 2011) German version EN ISO 7783 2011《油漆和清漆 水蒸气传输性质的测定 杯量法(.pdf
  • DIN EN ISO 7784-1-2016 Paints and varnishes - Determination of resistance to abrasion - Part 1 Method with abrasive-paper covered wheels and rotating test specimen (ISO 7784-1 2016.pdf DIN EN ISO 7784-1-2016 Paints and varnishes - Determination of resistance to abrasion - Part 1 Method with abrasive-paper covered wheels and rotating test specimen (ISO 7784-1 2016.pdf
  • DIN EN ISO 7784-2-2016 Paints and varnishes - Determination of resistance to abrasion - Part 2 Method with abrasive rubber wheels and rotating test specimen (ISO 7784-2 2016) Germa.pdf DIN EN ISO 7784-2-2016 Paints and varnishes - Determination of resistance to abrasion - Part 2 Method with abrasive rubber wheels and rotating test specimen (ISO 7784-2 2016) Germa.pdf
  • DIN EN ISO 7784-3-2016 Paints and varnishes - Determination of resistance to abrasion - Part 3 Method with abrasive-paper covered wheel and linearly reciprocating test specimen (IS.pdf DIN EN ISO 7784-3-2016 Paints and varnishes - Determination of resistance to abrasion - Part 3 Method with abrasive-paper covered wheel and linearly reciprocating test specimen (IS.pdf
  • DIN EN ISO 7786-2001 Dental rotary instruments - Laboratory abrasive instruments (ISO 7786 2001) German version EN ISO 7786 2001《牙科用旋转器械 实验室研磨器械 德文版本 EN ISO 7786 2001》.pdf DIN EN ISO 7786-2001 Dental rotary instruments - Laboratory abrasive instruments (ISO 7786 2001) German version EN ISO 7786 2001《牙科用旋转器械 实验室研磨器械 德文版本 EN ISO 7786 2001》.pdf
  • DIN EN ISO 7787-1-2016 Dentistry - Laboratory cutters - Part 1 Steel laboratory cutters (ISO 7787-1 2016) German version EN ISO 7787-1 2016《牙科 实验室刀具 第1部分 钢制实验室刀具(ISO 7787-1-2016) 德.pdf DIN EN ISO 7787-1-2016 Dentistry - Laboratory cutters - Part 1 Steel laboratory cutters (ISO 7787-1 2016) German version EN ISO 7787-1 2016《牙科 实验室刀具 第1部分 钢制实验室刀具(ISO 7787-1-2016) 德.pdf
  • 相关搜索

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

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