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

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

1、全国计算机二级 C 语言上机试题 74+2015 年及答案解析(总分:30.00,做题时间:90 分钟)1.人员的记录由编号和出生年、月、日组成,N 名人员的数据已在主函数中存入结构体数组 std 中。函数fun 的功能是:找出指定出生年份的人员,将其数据放在形参 k 所指的数组中,由主函数输出,同时由函数值返回满足指定条件的人数。 请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。 注意:源程序存放在考生文件夹下的 BLANK1.C 中。 不得增行或删行,也不得更改程序的结构!给定源程序: #include #define N 8 typedef struct int n

2、um; int year,month,day ; STU; int fun(STU *std, STU *k, int year) int i,n=0; for (i=0; i /*found*/ if( _1_=year) /*found*/ kn+= _2_; /*found*/ return (_3_); main() STU stdN= 1,1984,2,15,2,1983,9,21,3,1984,9,1,4,1983,7,15, 5,1985,9,28,6,1982,11,15,7,1982,6,22,8,1984,8,19; STU kN; int i,n,year; printf

3、Enter a year : “); scanf(“%d“, n=fun(std,k,year); if(n=0) printf(“/nNo person was born in %d /n“,year); else printf(“/nThese persons were born in %d /n“,year); for(i=0; i printf(“%d %d-%d-%d/n“,ki.num,ki.year,ki.month,ki.day); (分数:10.00)_2.给定程序 MODI1.C 的功能是:读入一个整数 k(2k10000),打印它的所有质因子(即所有为素数的因子)。

4、例如,若输入整数:2310,则应输出:2、3、5、7、11。 请改正程序中的语法错误,使程序能得出正确的结果。 注意:不要改动 main 函数,不得增行或删行,也不得更改程序的结构! 给定源程序: #include /*found*/ IsPrime ( int n ); int i, m; m = 1; for ( i = 2; i n; i+ ) /*found*/ if !( n%i ) m = 0; break ; return ( m ); main( ) int j, k; printf( “/nPlease enter an integer number between 2 an

5、d 10000: “ ); scanf( “%d“, printf( “/n/nThe prime factor(s) of %d is( are ):“, k ); for( j = 2; j = k; j+ ) if( ( !( k%j ) ) printf(“/n“); (分数:10.00)_3.已知学生的记录由学号和学习成绩构成,N 名学生的数据已存入结构体数组 a 中。请编写函数 fun,函数的功能是:找出成绩最高的学生记录,通过形参指针传回主函数(规定只有一个最高分)。已给出函数的首部,请完成该函数。 注意: 部分源程序存在文件 PROG1.C 中。 请勿改动主函数 main 和其

6、它函数中的任何内容,仅在函数 fun 的花括号中填入你编写的若干语句。 给定源程序: #include #include #define N 10 typedef struct ss char num10; int s; STU; fun( STU a, STU *s ) main ( ) STU aN= “A01“,81,“A02“,89,“A03“,66,“A04“,87,“A05“,77, “A06“,90,“A07“,79,“A08“,61,“A09“,80,“A10“,71 , m ; int i; printf(“* The original data */n“); for ( i

7、0; i N; i+ )printf(“No = %s Mark = %d/n“, ai.num,ai.s); fun ( a, printf (“* THE RESULT */n“); printf (“The top : %s , %d/n“,m.num, m.s); NONO( ); (分数:10.00)_全国计算机二级 C 语言上机试题 74+2015 年答案解析(总分:30.00,做题时间:90 分钟)1.人员的记录由编号和出生年、月、日组成,N 名人员的数据已在主函数中存入结构体数组 std 中。函数fun 的功能是:找出指定出生年份的人员,将其数据放在形参 k 所指的数组中,由

8、主函数输出,同时由函数值返回满足指定条件的人数。 请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。 注意:源程序存放在考生文件夹下的 BLANK1.C 中。 不得增行或删行,也不得更改程序的结构!给定源程序: #include #define N 8 typedef struct int num; int year,month,day ; STU; int fun(STU *std, STU *k, int year) int i,n=0; for (i=0; i /*found*/ if( _1_=year) /*found*/ kn+= _2_; /*found*/

9、return (_3_); main() STU stdN= 1,1984,2,15,2,1983,9,21,3,1984,9,1,4,1983,7,15, 5,1985,9,28,6,1982,11,15,7,1982,6,22,8,1984,8,19; STU kN; int i,n,year; printf(“Enter a year : “); scanf(“%d“, n=fun(std,k,year); if(n=0) printf(“/nNo person was born in %d /n“,year); else printf(“/nThese persons were bor

10、n in %d /n“,year); for(i=0; i printf(“%d %d-%d-%d/n“,ki.num,ki.year,ki.month,ki.day); (分数:10.00)_正确答案:(第一处:断结构变量中的编号 year 是否相等,所以应填:stdi.year。 第二处:把符合条件的记录依次存入实参 k 中,所以应填:stdi。 第三处:返回符合满足条件的人数,所以应填:n。)解析:2.给定程序 MODI1.C 的功能是:读入一个整数 k(2k10000),打印它的所有质因子(即所有为素数的因子)。 例如,若输入整数:2310,则应输出:2、3、5、7、11。 请改正程序

11、中的语法错误,使程序能得出正确的结果。 注意:不要改动 main 函数,不得增行或删行,也不得更改程序的结构! 给定源程序: #include /*found*/ IsPrime ( int n ); int i, m; m = 1; for ( i = 2; i n; i+ ) /*found*/ if !( n%i ) m = 0; break ; return ( m ); main( ) int j, k; printf( “/nPlease enter an integer number between 2 and 10000: “ ); scanf( “%d“, printf( “

12、/n/nThe prime factor(s) of %d is( are ):“, k ); for( j = 2; j = k; j+ ) if( ( !( k%j ) ) printf(“/n“); (分数:10.00)_正确答案:(第一处:函数定义的行尾有多余的分号。 第二处:条件判断缺少圆括号。)解析:3.已知学生的记录由学号和学习成绩构成,N 名学生的数据已存入结构体数组 a 中。请编写函数 fun,函数的功能是:找出成绩最高的学生记录,通过形参指针传回主函数(规定只有一个最高分)。已给出函数的首部,请完成该函数。 注意: 部分源程序存在文件 PROG1.C 中。 请勿改动主函数

13、main 和其它函数中的任何内容,仅在函数 fun 的花括号中填入你编写的若干语句。 给定源程序: #include #include #define N 10 typedef struct ss char num10; int s; STU; fun( STU a, STU *s ) main ( ) STU aN= “A01“,81,“A02“,89,“A03“,66,“A04“,87,“A05“,77, “A06“,90,“A07“,79,“A08“,61,“A09“,80,“A10“,71 , m ; int i; printf(“* The original data */n“); for ( i=0; i N; i+ )printf(“No = %s Mark = %d/n“, ai.num,ai.s); fun ( a, printf (“* THE RESULT */n“); printf (“The top : %s , %d/n“,m.num, m.s); NONO( ); (分数:10.00)_正确答案:(fun( STU a, STU *s ) int i, max = a0.s, j = 0; for(i = 1 ; i N ; i+) if(max ai.s) j = i ; max = ai.s ; *s = aj ; )解析:

展开阅读全文
相关资源
猜你喜欢
  • GOST 31643-2012 Juice products Determination of ascorbic acid by High Performance Liquid Chromatography (HPLC) method《果汁产品 高效液相色谱(HPLC)方法测定抗坏血酸》.pdf GOST 31643-2012 Juice products Determination of ascorbic acid by High Performance Liquid Chromatography (HPLC) method《果汁产品 高效液相色谱(HPLC)方法测定抗坏血酸》.pdf
  • GOST 31644-2012 Juice products Determination of 5-Hydroxymethylfurfural (HMF) by High Performance Liquid Chromatography (HPLC) method《5-羟甲基糠醛(HMF)的高效液相色谱测定法(HPLC)》.pdf GOST 31644-2012 Juice products Determination of 5-Hydroxymethylfurfural (HMF) by High Performance Liquid Chromatography (HPLC) method《5-羟甲基糠醛(HMF)的高效液相色谱测定法(HPLC)》.pdf
  • GOST 31645-2012 Flour for baby-s nutrition Specifications《婴儿营养粉状物 规格》.pdf GOST 31645-2012 Flour for baby-s nutrition Specifications《婴儿营养粉状物 规格》.pdf
  • GOST 31646-2012 Cereals Method for determination of scabby kernels content《谷物 结痂仁含量的测定方法》.pdf GOST 31646-2012 Cereals Method for determination of scabby kernels content《谷物 结痂仁含量的测定方法》.pdf
  • GOST 31649-2012 Decorative cosmetic stuffs on fatty and waxy basis General specifications《脂肪和蜡质基的装饰品 通用规格》.pdf GOST 31649-2012 Decorative cosmetic stuffs on fatty and waxy basis General specifications《脂肪和蜡质基的装饰品 通用规格》.pdf
  • GOST 31650-2012 Medical remedies for animals feed and feed additives Detection of mass fraction of mercury by atom absorbtion spectrometric method《动物医学治疗的饲料和饲料添加剂 检测汞质量分数的原子吸收光谱测定方.pdf GOST 31650-2012 Medical remedies for animals feed and feed additives Detection of mass fraction of mercury by atom absorbtion spectrometric method《动物医学治疗的饲料和饲料添加剂 检测汞质量分数的原子吸收光谱测定方.pdf
  • GOST 31651-2012 Medical remedies for animals feed and feed additives Detection of mass fraction of selenium by atom absorbtion spectrometric method《动物、饲料及饲料添加剂的医学治疗 通过原子吸收光谱测定方法检测硒.pdf GOST 31651-2012 Medical remedies for animals feed and feed additives Detection of mass fraction of selenium by atom absorbtion spectrometric method《动物、饲料及饲料添加剂的医学治疗 通过原子吸收光谱测定方法检测硒.pdf
  • GOST 31653-2012 Feedstuffs Method of immunoenzyme mycotoxin determination《饲料 免疫酶霉菌毒素的测定方法》.pdf GOST 31653-2012 Feedstuffs Method of immunoenzyme mycotoxin determination《饲料 免疫酶霉菌毒素的测定方法》.pdf
  • GOST 31655-2012 Food eggs (turkey guinea-fowl quail ostrich) Specifications《食用蛋类(火鸡、珍珠鸡、鹌鹑、鸵鸟) 规格》.pdf GOST 31655-2012 Food eggs (turkey guinea-fowl quail ostrich) Specifications《食用蛋类(火鸡、珍珠鸡、鹌鹑、鸵鸟) 规格》.pdf
  • 相关搜索

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

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