【计算机类职业资格】全国计算机二级C语言上机试题64+2015年及答案解析.doc

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

1、全国计算机二级 C 语言上机试题 64+2015 年及答案解析(总分:30.00,做题时间:90 分钟)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 请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。 注意:源程序存放在考生文件夹下的 BLANK1.C 中。不得增行或删行,也不得更改程序

2、的结构! 给定源程序: #include #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 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 before moving:/n/n“); for(

3、i=0; i for(j=0; jprintf(“/n“); fun(x,2); printf(“The array after moving:/n/n“); for(i=0; i for(j=0; jprintf(“/n“); (分数:10.00)_2.给定程序 MODI1.C 中函数 fun 的功能是:根据形参 m 的值(2m9,在 m 行 m 列的二维数组中存放如下所示规律的数据,由 main 函数输出。 例如,若输入 2 | 若输入 4 则输出: | 则输出: 1 2 | 1 2 3 4 2 4 | 2 4 6 8 | 3 6 9 12 | 4 8 12 16 请改正程序函数中的错误,

4、使它能得出正确的结果。 注意:不要改动 main 函数,不得增行或删行,也不得更改程序的结构! 给定源程序: #include #define M 10 int aMM = 0 ; /*found*/ fun(int *a, int m) int j, k ; for (j = 0 ; j m ; j+ ) for (k = 0 ; k m ; k+ ) /*found*/ ajk = k * j ; main ( ) int i, j, n ; printf ( “ Enter n : “ ) ; scanf (“%d“, fun ( a, n ) ; for ( i = 0 ; i n ;

5、 i+) for (j = 0 ; j n ; j+) printf ( “M“, aij ) ; printf ( “/n“ ) ; (分数:10.00)_3.函数 fun 的功能是:将 a、b 中的两个两位正整数合并形成一个新的整数放在 c 中。合并的方式是:将 a中的十位和个位数依次放在变量 c 的十位和千位上,b 中的十位和个位数依次放在变量 c 的个位和百位上。例如,当 a45,b=12。调用该函数后,c=5241。 注意: 部分源程序存在文件 PROG1.C 中。数据文件IN.DAT 中的数据不得修改。 请勿改动主函数 main 和其它函数中的任何内容,仅在函数 fun 的花括号中

6、填入你编写的若干语句。 给定源程序: #include void fun(int a, int b, long *c) main() int a,b; long c; printf(“Input a, b:“); scanf(“%d%d“, fun(a, b, printf(“The result is: %ld/n“, c); NONO(); (分数:10.00)_全国计算机二级 C 语言上机试题 64+2015 年答案解析(总分:30.00,做题时间:90 分钟)1.给定程序中,函数 fun 的功能是:将 a 所指 35 矩阵中第 k 列的元素左移到第 0 列,第 k 列以后的每列元素行依

7、次左移,原来左边的各列依次绕到右边。 例如,有下列矩阵: 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 请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。 注意:源程序存放在考生文件夹下的 BLANK1.C 中。不得增行或删行,也不得更改程序的结构! 给定源程序: #include #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+

8、) for(i=0; 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 before moving:/n/n“); for(i=0; i for(j=0; jprintf(“/n“); fun(x,2); printf(“The array after moving:/n/n“); for(i=0; i for(j=0; jprintf(“/n“); (

9、分数:10.00)_正确答案:(第一处:外循环 p 的终止变量的值,试题要求第 k 列左移,所以应填:k。 第二处:矩阵共N 列,所以应填:N-1。 第三处:把存放在临时变量 temp 中的值,放到 aiN-1中,所以应填:temp。)解析:2.给定程序 MODI1.C 中函数 fun 的功能是:根据形参 m 的值(2m9,在 m 行 m 列的二维数组中存放如下所示规律的数据,由 main 函数输出。 例如,若输入 2 | 若输入 4 则输出: | 则输出: 1 2 | 1 2 3 4 2 4 | 2 4 6 8 | 3 6 9 12 | 4 8 12 16 请改正程序函数中的错误,使它能得出

10、正确的结果。 注意:不要改动 main 函数,不得增行或删行,也不得更改程序的结构! 给定源程序: #include #define M 10 int aMM = 0 ; /*found*/ fun(int *a, int m) int j, k ; for (j = 0 ; j m ; j+ ) for (k = 0 ; k m ; k+ ) /*found*/ ajk = k * j ; main ( ) int i, j, n ; printf ( “ Enter n : “ ) ; scanf (“%d“, fun ( a, n ) ; for ( i = 0 ; i n ; i+)

11、for (j = 0 ; j n ; j+) printf ( “M“, aij ) ; printf ( “/n“ ) ; (分数:10.00)_正确答案:(第一处:在函数体 fun 中可知,a 是一个字符串数组型变量,所以应改为:fun(int aM,int m)。 第二处:根据输出的结果可知,应改为:ajk=(k+1)*(j+1);。)解析:3.函数 fun 的功能是:将 a、b 中的两个两位正整数合并形成一个新的整数放在 c 中。合并的方式是:将 a中的十位和个位数依次放在变量 c 的十位和千位上,b 中的十位和个位数依次放在变量 c 的个位和百位上。例如,当 a45,b=12。调用该函数后,c=5241。 注意: 部分源程序存在文件 PROG1.C 中。数据文件IN.DAT 中的数据不得修改。 请勿改动主函数 main 和其它函数中的任何内容,仅在函数 fun 的花括号中填入你编写的若干语句。 给定源程序: #include void fun(int a, int b, long *c) main() int a,b; long c; printf(“Input a, b:“); scanf(“%d%d“, fun(a, b, printf(“The result is: %ld/n“, c); NONO(); (分数:10.00)_正确答案:( )解析:

展开阅读全文
相关资源
猜你喜欢
  • BS PD IEC TS 62763-2013_5284 Pilot function through a control pilot circuit using PWM (pulse width modulation) and a control pilot wire《通过控制导向线使用PWM (脉冲宽度调制) 的导向功能和控制导向线》.pdf BS PD IEC TS 62763-2013_5284 Pilot function through a control pilot circuit using PWM (pulse width modulation) and a control pilot wire《通过控制导向线使用PWM (脉冲宽度调制) 的导向功能和控制导向线》.pdf
  • BS ISO 8070-2007 Milk and milk products - Determination of calcium sodium potassium and magnesium contents - Atomic absorption spectrometric method《牛奶和奶制品 钙、钠、钾和镁含量的测定 原子吸.pdf BS ISO 8070-2007 Milk and milk products - Determination of calcium sodium potassium and magnesium contents - Atomic absorption spectrometric method《牛奶和奶制品 钙、钠、钾和镁含量的测定 原子吸.pdf
  • BS ISO 8082-1-2009 Self-propelled machinery for forestry - Laboratory tests and performance requirements for roll-over protective structures - General machines《林业用自推进机械 防倾.pdf BS ISO 8082-1-2009 Self-propelled machinery for forestry - Laboratory tests and performance requirements for roll-over protective structures - General machines《林业用自推进机械 防倾.pdf
  • BS ISO 8082-2-2011 Self-propelled machinery for forestry Laboratory tests and performance requirements for roll-over protective structures Machines having a rotating platf.pdf BS ISO 8082-2-2011 Self-propelled machinery for forestry Laboratory tests and performance requirements for roll-over protective structures Machines having a rotating platf.pdf
  • BS ISO 8083-2006 Machinery for forestry - Falling-object protective structures (FOPS) - Laboratory tests and performance requirements《林业机械 落体防护装置(FOPS) 实验室试验和性能要求》.pdf BS ISO 8083-2006 Machinery for forestry - Falling-object protective structures (FOPS) - Laboratory tests and performance requirements《林业机械 落体防护装置(FOPS) 实验室试验和性能要求》.pdf
  • BS ISO 8086-2004 Dairy plant - Hygiene conditions - General guidance on inspection and sampling procedures《乳品厂 卫生条件 检验和取样程序通用指南》.pdf BS ISO 8086-2004 Dairy plant - Hygiene conditions - General guidance on inspection and sampling procedures《乳品厂 卫生条件 检验和取样程序通用指南》.pdf
  • BS ISO 8096-2005 Rubber- or plastics-coated fabrics for water resistant clothing - Specification《雨衣用橡胶或塑料涂覆织物 规范》.pdf BS ISO 8096-2005 Rubber- or plastics-coated fabrics for water resistant clothing - Specification《雨衣用橡胶或塑料涂覆织物 规范》.pdf
  • BS ISO 8097-2001 Aircraft Minimum airworthiness requirements and test conditions for certified air cargo unit load devices《航空器 经认证的航空货运集装单元装置最低适航性要求和试验条件》.pdf BS ISO 8097-2001 Aircraft Minimum airworthiness requirements and test conditions for certified air cargo unit load devices《航空器 经认证的航空货运集装单元装置最低适航性要求和试验条件》.pdf
  • BS ISO 8114-1993 Textile machinery and accessories - Spindles for ring-spinning and doubling machines - List of equivalent terms《纺织机械和附件 环锭纺纱机和并线机用锭子 同义术语表》.pdf BS ISO 8114-1993 Textile machinery and accessories - Spindles for ring-spinning and doubling machines - List of equivalent terms《纺织机械和附件 环锭纺纱机和并线机用锭子 同义术语表》.pdf
  • 相关搜索

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

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