【计算机类职业资格】国家二级C语言机试(操作题)模拟试卷427及答案解析.doc

上传人:explodesoak291 文档编号:1332241 上传时间:2019-10-17 格式:DOC 页数:2 大小:37KB
下载 相关 举报
【计算机类职业资格】国家二级C语言机试(操作题)模拟试卷427及答案解析.doc_第1页
第1页 / 共2页
【计算机类职业资格】国家二级C语言机试(操作题)模拟试卷427及答案解析.doc_第2页
第2页 / 共2页
亲,该文档总共2页,全部预览完了,如果喜欢就下载吧!
资源描述

1、国家二级 C语言机试(操作题)模拟试卷 427及答案解析(总分:6.00,做题时间:90 分钟)一、程序填空题(总题数:1,分数:2.00)1.给定程序中,函数 fun的功能是: 将 a所指 35矩阵中第 k列的元素左移到第 0列,第 k列以后的每列元素行依次左移,原来左边的各列依次绕到右边。 例如,有下列矩阵: 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 若 k为 2,程序执行结果为 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 请在程序的下画线处填入正确的内容并把下画线删除,使程序得出正确的结果。 注意:部分源程序在文件 BLANK1C 中。 不得增行或删行,

2、也不得更改程序的结构! 试题程序: #1F1clude stdioh #define M 3 #define N 5 void fun(int(* a)N,int k) (int i,j,p,temp; /*found*/ for(p=1;p = 【1】 ;p+) for(i=0;i M;i+) temp=ai0; /*found*/ for(j=0; j 【2】 ;j+) aij_aij+1; /*found*/ aiN 一 1= 【3】 ; main() int xMN=1,2,3,4,5), 1,2,3,4,5),1,2,3,4,5),i,j; printf(“The array bef

3、ore moving:/n/n“); for(i=0; i M;i+) for(j=0;j N;j+) printf(“3 d“,xij);printf(“/n“); fun(x,2); printf(“The array after moving:/n/n“); for(i=0;i M;i+) for(j=0;j N;j+) prLntf(“3d“,xij); printf(“/n“); (分数:2.00)_二、程序修改题(总题数:1,分数:2.00)2.下列给定程序中,函数 fun的功能是:根据形参 m的值(2m9),在 m行 m列的二维数组中存放如下所示规律的数据,由 main函数输出。

4、 (分数:2.00)_三、程序设计题(总题数:1,分数:2.00)3.函数 fun的功能是:将 a、b 中的两个正整数合并形成一个新的整数放在 c中。合并的方式是:将 a中的十位和个位数依次放在变量 c的十位和千位上,b 中的十位和个位数依次放在变量 c的个位和百位上。 例如,当 a=45,b=12。调用该函数后,c=5241。 注意:部分源程序在文件 PROG1C 中。 请勿改动 main函数和其他函数中的任何内容,仅在函数 fun的花括号中填入你编写的若干语句。试题程序:#include stdioh void fun(int a,int b,long*c)main()int a,b;lo

5、ng c;void NONO(); printf(“Input a,b:“); scanf(“dd“,&a,&b); fun(a,b,&c); printf(“The result is:id/n“,c); NONO();void NONO()/*本函数用于打开文件,输入数据,调用函数,输出数据,关闭文件。*/ FTT*rf,*wf; int i,a,b;long c; rf:fopen(“indat“,“r“); wf=fopen(“outdat“,“w“); for(i=0;i 10;i+) fscanf(rf,“d,d“,&a,&b); fun(a,b,&c); fprintf(wf,“

6、a=d,b=d,c=ld/n“,a,b,c); fclose(rf); fclose(wf);(分数:2.00)_国家二级 C语言机试(操作题)模拟试卷 427答案解析(总分:6.00,做题时间:90 分钟)一、程序填空题(总题数:1,分数:2.00)1.给定程序中,函数 fun的功能是: 将 a所指 35矩阵中第 k列的元素左移到第 0列,第 k列以后的每列元素行依次左移,原来左边的各列依次绕到右边。 例如,有下列矩阵: 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 若 k为 2,程序执行结果为 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 请在程序的下画线处填入

7、正确的内容并把下画线删除,使程序得出正确的结果。 注意:部分源程序在文件 BLANK1C 中。 不得增行或删行,也不得更改程序的结构! 试题程序: #1F1clude stdioh #define M 3 #define N 5 void fun(int(* a)N,int k) (int i,j,p,temp; /*found*/ for(p=1;p = 【1】 ;p+) for(i=0;i M;i+) temp=ai0; /*found*/ for(j=0; j 【2】 ;j+) aij_aij+1; /*found*/ aiN 一 1= 【3】 ; main() int xMN=1,2,

8、3,4,5), 1,2,3,4,5),1,2,3,4,5),i,j; printf(“The array before moving:/n/n“); for(i=0; i M;i+) for(j=0;j N;j+) printf(“3 d“,xij);printf(“/n“); fun(x,2); printf(“The array after moving:/n/n“); for(i=0;i M;i+) for(j=0;j N;j+) prLntf(“3d“,xij); printf(“/n“); (分数:2.00)_正确答案:(正确答案:(1)k (2)N 一 1 (3)temp)解析:解

9、析:填空 1:外循环 p的值为数组移动的次数,试题要求第 k列左移,则需要移动的次数为 k,所以应填 k。 填空 2:矩阵共 N列,所以应填 N 一 1。 填空 3:临时变量 temp中存放的值为数组最左边元素的值,需要把 temp放到数组的末尾,即放到 aiN一 1中,所以应填 temp。二、程序修改题(总题数:1,分数:2.00)2.下列给定程序中,函数 fun的功能是:根据形参 m的值(2m9),在 m行 m列的二维数组中存放如下所示规律的数据,由 main函数输出。 (分数:2.00)_正确答案:(正确答案:(1)void fun(int aM,int m) (2)ajk=(k+1)*

10、(j+1);)解析:解析:(1)在函数体 fun中可知,a 是一个二维整型数组变量,设置实参时,用*a 表示是错误的,所以应改为 void fun(int aM,int m)。 (2)根据输出的结果可知,应改为 ajk=(k+1)*(j+1);。三、程序设计题(总题数:1,分数:2.00)3.函数 fun的功能是:将 a、b 中的两个正整数合并形成一个新的整数放在 c中。合并的方式是:将 a中的十位和个位数依次放在变量 c的十位和千位上,b 中的十位和个位数依次放在变量 c的个位和百位上。 例如,当 a=45,b=12。调用该函数后,c=5241。 注意:部分源程序在文件 PROG1C 中。

11、请勿改动 main函数和其他函数中的任何内容,仅在函数 fun的花括号中填入你编写的若干语句。试题程序:#include stdioh void fun(int a,int b,long*c)main()int a,b;long c;void NONO(); printf(“Input a,b:“); scanf(“dd“,&a,&b); fun(a,b,&c); printf(“The result is:id/n“,c); NONO();void NONO()/*本函数用于打开文件,输入数据,调用函数,输出数据,关闭文件。*/ FTT*rf,*wf; int i,a,b;long c; r

12、f:fopen(“indat“,“r“); wf=fopen(“outdat“,“w“); for(i=0;i 10;i+) fscanf(rf,“d,d“,&a,&b); fun(a,b,&c); fprintf(wf,“a=d,b=d,c=ld/n“,a,b,c); fclose(rf); fclose(wf);(分数:2.00)_正确答案:(正确答案:void fun (int a, int b, long*c) *c = (a10 ) * 1000 + (b/0 ) * 100 + (a/10) *10 + (b/10) ; )解析:解析:本题是给出两个两位数的正整数分别取出各位上的数字,再按条件组成一个新数。取 a十位数字的方法 a/10,取 a个位数字的方法 a10。同理可取出整数 b的个位数和十位数。

展开阅读全文
相关资源
猜你喜欢
  • SIS SS-ISO 8823-1989 Information processing systems  Open Systems Interconnection  Connection oriented presentation protocol specification《信息处理系统 开放式系统互连 连接表示协议规范》.pdf SIS SS-ISO 8823-1989 Information processing systems Open Systems Interconnection Connection oriented presentation protocol specification《信息处理系统 开放式系统互连 连接表示协议规范》.pdf
  • SIS SS-ISO 8824-1991 Information technology  Open Systems Interconnection  Specification of Abstract Syntax Notation One (ASIM 1)《信息技术 开放式系统互连 抽象语法记法1规范(ASN 1)》.pdf SIS SS-ISO 8824-1991 Information technology Open Systems Interconnection Specification of Abstract Syntax Notation One (ASIM 1)《信息技术 开放式系统互连 抽象语法记法1规范(ASN 1)》.pdf
  • SIS SS-ISO 8825-1991 Information technology  Open Systems Interconnection  Specification of Basic Encoding Rules for Abstract Syntax Notation One(ASN I)《信息技术 开放式系统互连 抽象语法记法1(ASN 1).pdf SIS SS-ISO 8825-1991 Information technology Open Systems Interconnection Specification of Basic Encoding Rules for Abstract Syntax Notation One(ASN I)《信息技术 开放式系统互连 抽象语法记法1(ASN 1).pdf
  • SIS SS-ISO 8826-1-1991 Technical drawings  Rolling bearings  Part 1 General simplified representation《技术制图 滚动轴承 第1部分:一般简易陈述》.pdf SIS SS-ISO 8826-1-1991 Technical drawings Rolling bearings Part 1 General simplified representation《技术制图 滚动轴承 第1部分:一般简易陈述》.pdf
  • SIS SS-ISO 8829-1991 Aerospace  Polytetrafluoroethylene (PTFE) hose assemblies  Test methods《航空航天 聚四氟乙烯(PTFE)软管组件 测试方法》.pdf SIS SS-ISO 8829-1991 Aerospace Polytetrafluoroethylene (PTFE) hose assemblies Test methods《航空航天 聚四氟乙烯(PTFE)软管组件 测试方法》.pdf
  • SIS SS-ISO 8831-1989 Information processing Systems  Open Systems Interconnection  Job transfer and manipulation concepts and services (JTM)《信息处理系统 开放式系统互连 互连作业传送和操纵的概念与服务(JTM)》.pdf SIS SS-ISO 8831-1989 Information processing Systems Open Systems Interconnection Job transfer and manipulation concepts and services (JTM)《信息处理系统 开放式系统互连 互连作业传送和操纵的概念与服务(JTM)》.pdf
  • SIS SS-ISO 8832-1989 Information processing systems  Open Systems Interconnection  Specification of the basic dass protocol for job transfer and manipulation (JTM)《信息处理系统 开放式系统互连 作.pdf SIS SS-ISO 8832-1989 Information processing systems Open Systems Interconnection Specification of the basic dass protocol for job transfer and manipulation (JTM)《信息处理系统 开放式系统互连 作.pdf
  • SIS SS-ISO 8853-1991 Safety harnesses for competition drivers  Requirements and test methods《竞赛司机安全带 要求和测试方法》.pdf SIS SS-ISO 8853-1991 Safety harnesses for competition drivers Requirements and test methods《竞赛司机安全带 要求和测试方法》.pdf
  • SIS SS-ISO 8854-1989 Road vehicles  Alternators with regulators  Test methods and general requirements《道路车辆 带稳压器的交流发电机》.pdf SIS SS-ISO 8854-1989 Road vehicles Alternators with regulators Test methods and general requirements《道路车辆 带稳压器的交流发电机》.pdf
  • 相关搜索

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

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