【计算机类职业资格】二级C语言-325 (1)及答案解析.doc

上传人:ownview251 文档编号:1325215 上传时间:2019-10-17 格式:DOC 页数:6 大小:34KB
下载 相关 举报
【计算机类职业资格】二级C语言-325 (1)及答案解析.doc_第1页
第1页 / 共6页
【计算机类职业资格】二级C语言-325 (1)及答案解析.doc_第2页
第2页 / 共6页
【计算机类职业资格】二级C语言-325 (1)及答案解析.doc_第3页
第3页 / 共6页
【计算机类职业资格】二级C语言-325 (1)及答案解析.doc_第4页
第4页 / 共6页
【计算机类职业资格】二级C语言-325 (1)及答案解析.doc_第5页
第5页 / 共6页
点击查看更多>>
资源描述

1、二级 C 语言-325 (1)及答案解析(总分:100.00,做题时间:90 分钟)一、程序填空题(总题数:1,分数:30.00)1.请补充函数 proc(),该函数的功能是把数组 arr 中的奇数元素按原来的先后顺序放在原数组后面。 例如,原始数组为“33 67 42 58 25 76 85 16 41 55”,则输出结果为“42 58 76 16 33 67 25 85 41 55”。 注意:部分源程序给出如下。 请勿改动 main()函数和其他函数中的任何内容,仅在函数 proc()的横线上填入所编写的若干表达式或语句。 试题程序: #includestdlib.h #includest

2、dio.h #define M 10 void proc(int arr) int i, j=0, k=0; int bbM; for(i=0; iM; i+) if( 1) bbk+=arri; else arrj+=arri; for(i=0; ik; 2) arrj=bbi; void main() int i; int arrM=33, 67, 42, 58, 25, 76, 85, 16, 41, 55; system(“CLS“); printf(“/n*original list*/n“); for(i=0; iM; i+) printf(“%4d“, arri); proc(a

3、rr); printf(“/n*new list*/n“); for(i=0; iM; i+) printf(“%4d“, arri); (分数:30.00)二、程序改错题(总题数:1,分数:40.00)2.下列给定程序中,函数 proc()的功能是:依次取出字符串中所有的字母字符,形成新的字符串,并取代原字符串。 例如,若输入的字符串是:“ab232bd34bkw”,则输出结果是:“abbdbkw”。 请修改程序中的错误,使它能得到正确结果。 注意:不要改动 main()函数,不得增行或删行,也不得更改程序的结构。 试题程序: #includestdlib.h #includestdio.h

4、 #includeconio.h void proc(char*str) int i, j; for(i=0, j=0; stri!=“/0“; i+) /*found* if(stri=“A“ /*found* strj=“/0“; void main() char item80; system(“CLS“); printf(“/nEnter a string: “); gets(item); printf(“/n/nThe string is: %s/n“, item); proc(item); printf(“/n/nThe string of changing is: %s/n“, i

5、tem); (分数:40.00)_三、程序设计题(总题数:1,分数:30.00)3.学生的记录由学号和成绩组成,M 名学生的数据已在主函数中放入结构体数组 s 中,请编写函数 proc(),它的功能是:把分数最高的学生数据放在 h 所指的数组中。注意:分数最高的学生可能不止一个,函数返回分数最高学生的人数。 注意:部分源程序给出如下。 请勿改动 main()函数和其他函数中的任何内容,仅在函数 proc()的花括号中填入所编写的若干语句。 试题程序: #includestdio.h #define M 16 typedef struct char num10; int s; STREC; in

6、t proc(STREC*a, STREC*b) void main() STREC stuM=“GA005“, 85, “GA003“, 76, “GA002“, 69, “GA004“, 85, “GA001“, 91, “GA007“, 72, “GA008“, 64, “GA006“, 87, “GA015“, 85, “GA013“, 91, “GA012“, 64, “GA014“, 91, “GA011“, 66, “GA017“, 64, “GA018“, 64, “GA016“, 72; STREC hM; int i, n; n=proc(stu, h); printf(“

7、The %d highest score: /n“, n); for(i=0; in; i+) printf(“%s%4d/n“, hi.num, hi.s); /输出最高分学生的学号和成绩 printf(“/n“); (分数:30.00)_二级 C 语言-325 (1)答案解析(总分:100.00,做题时间:90 分钟)一、程序填空题(总题数:1,分数:30.00)1.请补充函数 proc(),该函数的功能是把数组 arr 中的奇数元素按原来的先后顺序放在原数组后面。 例如,原始数组为“33 67 42 58 25 76 85 16 41 55”,则输出结果为“42 58 76 16 33

8、67 25 85 41 55”。 注意:部分源程序给出如下。 请勿改动 main()函数和其他函数中的任何内容,仅在函数 proc()的横线上填入所编写的若干表达式或语句。 试题程序: #includestdlib.h #includestdio.h #define M 10 void proc(int arr) int i, j=0, k=0; int bbM; for(i=0; iM; i+) if( 1) bbk+=arri; else arrj+=arri; for(i=0; ik; 2) arrj=bbi; void main() int i; int arrM=33, 67, 42

9、 58, 25, 76, 85, 16, 41, 55; system(“CLS“); printf(“/n*original list*/n“); for(i=0; iM; i+) printf(“%4d“, arri); proc(arr); printf(“/n*new list*/n“); for(i=0; iM; i+) printf(“%4d“, arri); (分数:30.00)解析:arri%2!=0 或 arri%2=1 i+, j+解析 要把数组中的奇数元素放在原数组后面,首先要把原数组中所有的奇数元素选择出来再放在临时数组 bb 中,因此第一处填“arri%2!=0”;

10、最后要把选择出来的奇数元素放在原数组后面,因此第二处填“i+, j+”。二、程序改错题(总题数:1,分数:40.00)2.下列给定程序中,函数 proc()的功能是:依次取出字符串中所有的字母字符,形成新的字符串,并取代原字符串。 例如,若输入的字符串是:“ab232bd34bkw”,则输出结果是:“abbdbkw”。 请修改程序中的错误,使它能得到正确结果。 注意:不要改动 main()函数,不得增行或删行,也不得更改程序的结构。 试题程序: #includestdlib.h #includestdio.h #includeconio.h void proc(char*str) int i,

11、 j; for(i=0, j=0; stri!=“/0“; i+) /*found* if(stri=“A“ /*found* strj=“/0“; void main() char item80; system(“CLS“); printf(“/nEnter a string: “); gets(item); printf(“/n/nThe string is: %s/n“, item); proc(item); printf(“/n/nThe string of changing is: %s/n“, item); (分数:40.00)_正确答案:()解析:(1)错误:if(si=“A“

12、正确:strij=“/0“; 解析 判断一个字符是否是字母字符,只要这个字符符合大写字母或小写字母的其中一种情况即可,因此“if(si=“A“”应改为“sj=“/0“;”。三、程序设计题(总题数:1,分数:30.00)3.学生的记录由学号和成绩组成,M 名学生的数据已在主函数中放入结构体数组 s 中,请编写函数 proc(),它的功能是:把分数最高的学生数据放在 h 所指的数组中。注意:分数最高的学生可能不止一个,函数返回分数最高学生的人数。 注意:部分源程序给出如下。 请勿改动 main()函数和其他函数中的任何内容,仅在函数 proc()的花括号中填入所编写的若干语句。 试题程序: #in

13、cludestdio.h #define M 16 typedef struct char num10; int s; STREC; int proc(STREC*a, STREC*b) void main() STREC stuM=“GA005“, 85, “GA003“, 76, “GA002“, 69, “GA004“, 85, “GA001“, 91, “GA007“, 72, “GA008“, 64, “GA006“, 87, “GA015“, 85, “GA013“, 91, “GA012“, 64, “GA014“, 91, “GA011“, 66, “GA017“, 64, “

14、GA018“, 64, “GA016“, 72; STREC hM; int i, n; n=proc(stu, h); printf(“The %d highest score: /n“, n); for(i=0; in; i+) printf(“%s%4d/n“, hi.num, hi.s); /输出最高分学生的学号和成绩 printf(“/n“); (分数:30.00)_正确答案:()解析:int proc(STREC*a, STREC*b) int i, j=0, max=a0.s; /max 存放最高分数 for(i=0; iM; i+) if(maxai.s)max=ai.s; /把分数最高的学生数据放在 h 所指的数组中 for(i=0; iM; i+) if(max=ai.s)bj+=ai; /分数最高的学生可能不止一个 return j; 解析 要得到分数最高的学生数据,首先应检查每一个学生的数据,得到学生的最高成绩。成绩最高的学生不止一个,将每一个学生的成绩与最高成绩相比较,得出最高成绩学生的个数,将成绩最高的学生记录放在指定数组中通过形参返回。成绩最高的学生个数由函数值返回给主函数。

展开阅读全文
相关资源
猜你喜欢
  • SAE AMS 3793 1B-2013 Tape and Webbing Textile Para-Aramid Intermediate Modulus 1 2 Inch (12 5 Mm) 0 06 to 0 56 Ounces Per Yard (1 9 to 17 4 G M)《对芳族中间模数为1 2英寸(12 5 Mm)、每码0 06-0 56盎.pdf SAE AMS 3793 1B-2013 Tape and Webbing Textile Para-Aramid Intermediate Modulus 1 2 Inch (12 5 Mm) 0 06 to 0 56 Ounces Per Yard (1 9 to 17 4 G M)《对芳族中间模数为1 2英寸(12 5 Mm)、每码0 06-0 56盎.pdf
  • SAE AMS 3793 2B-2013 Tape and Webbing Textile Para-Aramid Intermediate Modulus 9 16 Inch (14 Mm) 0 08 to 0 13 Ounces Per Yard (2 5 to 4 0 G M)《对芳香聚酰胺中间模数为9 16英寸(14 Mm)、每线性码0 08-0 1.pdf SAE AMS 3793 2B-2013 Tape and Webbing Textile Para-Aramid Intermediate Modulus 9 16 Inch (14 Mm) 0 08 to 0 13 Ounces Per Yard (2 5 to 4 0 G M)《对芳香聚酰胺中间模数为9 16英寸(14 Mm)、每线性码0 08-0 1.pdf
  • SAE AMS 3793 3B-2013 Tape and Webbing Textile Para-Aramid Intermediate Modulus 3 4 Inch (19 mm) 0 11 to 0 60 Ounces per Yard (3 4 to 18 6 g m) (Stabilized Type)《对芳香聚酰胺中间模数为3 4英寸(19.pdf SAE AMS 3793 3B-2013 Tape and Webbing Textile Para-Aramid Intermediate Modulus 3 4 Inch (19 mm) 0 11 to 0 60 Ounces per Yard (3 4 to 18 6 g m) (Stabilized Type)《对芳香聚酰胺中间模数为3 4英寸(19.pdf
  • SAE AMS 3793 3C-2017 Tape and Webbing Textile Para-Aramid Intermediate Modulus 3 4 Inch (19 mm) 0 11 to 0 60 Ounces per Yard (3 4 to 18 6 g m).pdf SAE AMS 3793 3C-2017 Tape and Webbing Textile Para-Aramid Intermediate Modulus 3 4 Inch (19 mm) 0 11 to 0 60 Ounces per Yard (3 4 to 18 6 g m).pdf
  • SAE AMS 3793 4B-2013 Tape and Webbing Textile Para-Aramid Intermediate Modulus 1 Inch (25 Mm) 0 08 to 1 65 Ounces Per Yard (2 5 to 51 2 G M)《对芳族中间模数为5 16英寸(9 7mm)、每码0 053盎司(1 64g m.pdf SAE AMS 3793 4B-2013 Tape and Webbing Textile Para-Aramid Intermediate Modulus 1 Inch (25 Mm) 0 08 to 1 65 Ounces Per Yard (2 5 to 51 2 G M)《对芳族中间模数为5 16英寸(9 7mm)、每码0 053盎司(1 64g m.pdf
  • SAE AMS 3793 5B-2013 Tape and Webbing Textile Para-Aramid Intermediate Modulus 1-1 8 Inch (28 Mm) 0 23 to 2 00 Ounces Per Yard (7 1 to 62 0 G M)《对芳香聚酰胺中间模数为1-1 8英寸(28 Mm)、每码0 23-2 .pdf SAE AMS 3793 5B-2013 Tape and Webbing Textile Para-Aramid Intermediate Modulus 1-1 8 Inch (28 Mm) 0 23 to 2 00 Ounces Per Yard (7 1 to 62 0 G M)《对芳香聚酰胺中间模数为1-1 8英寸(28 Mm)、每码0 23-2 .pdf
  • SAE AMS 3793 6B-2013 Tape and Webbing Textile Para-Aramid Intermediate Modulus 1-1 4 Inch (31 Mm) 0 23 Ounces Per Yard (7 1 G M)《对芳族中间模数为1-1 4英寸(31mm)、每码0 23盎司(7 1g m)的纺织带和网》.pdf SAE AMS 3793 6B-2013 Tape and Webbing Textile Para-Aramid Intermediate Modulus 1-1 4 Inch (31 Mm) 0 23 Ounces Per Yard (7 1 G M)《对芳族中间模数为1-1 4英寸(31mm)、每码0 23盎司(7 1g m)的纺织带和网》.pdf
  • SAE AMS 3793 7B-2013 Tape and Webbing Textile Para-Aramid Intermediate Modulus 1-1 2 Inch (37 5 Mm) 0 12 to 0 47 Ounces Per Yard (3 7 to 14 6 G M)《0 12至0 47 盎司每码 (3 7 G M) 的对位芳纶中间模.pdf SAE AMS 3793 7B-2013 Tape and Webbing Textile Para-Aramid Intermediate Modulus 1-1 2 Inch (37 5 Mm) 0 12 to 0 47 Ounces Per Yard (3 7 to 14 6 G M)《0 12至0 47 盎司每码 (3 7 G M) 的对位芳纶中间模.pdf
  • SAE AMS 3793 8B-2013 Tape and Webbing Textile Para-Aramid Intermediate Modulus 1-3 4 Inch (44 Mm) 0 17 to 2 50 Ounces Per Yard (5 3 to 77 5 G M)《 0 17至2 50 盎司每码(5 3至77 5 G M) 对位芳纶中.pdf SAE AMS 3793 8B-2013 Tape and Webbing Textile Para-Aramid Intermediate Modulus 1-3 4 Inch (44 Mm) 0 17 to 2 50 Ounces Per Yard (5 3 to 77 5 G M)《 0 17至2 50 盎司每码(5 3至77 5 G M) 对位芳纶中.pdf
  • 相关搜索

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

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