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

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

1、二级 C 语言-312 (1)及答案解析(总分:100.00,做题时间:90 分钟)一、程序填空题(总题数:1,分数:30.00)1.请补充 main()函数,该函数的功能是:输出一个 44 的矩阵,要求必须使用行指针表示输出变量。 注意:部分源程序给出如下。 请勿改动 main()函数和其他函数中的任何内容,仅在 main()函数的横线上填入所编写的若干表达式或语句。 试题程序: #includestdlib.h #includestdio.h void main() static int art44=9, 8, 7, 6, 6, 5, 4, 3, 3, 2, 1, 0, 2, 4, 6,

2、8; int(*p)4, j, i; p= 1; system(“CLS“); for(i=0; i4; i+) printf(“/n/n“); for(j=0; j4; j+) printf(“%4d“, 2); (分数:30.00)二、程序改错题(总题数:1,分数:40.00)2.下列给定程序中,函数 proc()的功能是:依次取出字符串中所有的数字字符,形成新的字符串,并取代原字符串。例如原始字符串是“ab45c6djfd789”,则输出后的字符是“456789”。 请修改函数 proc()中的错误,使它能得出正确的结果。 注意:不要改动 main()函数,不得增行或删行,也不得更改程序

3、的结构。 试题程序: #includestdlib.h #includestdio.h #includeconio.h void proc(char*s) int i, j; for(i=0, j=0; si!=“/0“; i+) if(si=“0“ /*found* sj=“/0“; void main() char str80; system(“CLS“); printf(“/nEnter a string:“); gets(str); printf(“/n/nThe string is:%s/n“, str); proc(str); printf(“/n/nThe siring of c

4、hanging is: %s/n“, str); (分数:40.00)_三、程序设计题(总题数:1,分数:30.00)3.学生的记录由学号和成绩组成,M 名学生的数据已在主函数中放入结构体数组 stu 中,请编写函数proc(),它的功能是:把指定分数范围内的学生数据放在 b 所指的数组中,分数范围内的学生人数由函数值返回。 例如,输入的分数是 7079,则应当把分数在 7079 的学生数据进行输出,包含 70 分和 79 分的学生数据。主函数中把 70 放在 low 中,把 79 放在 heigh 中。 注意:部分源程序给出如下。 请勿改动 main()函数和其他函数中的任何内容,仅在函数

5、proc 的花括号中填入所编写的若干语句。 试题程序: #includestdio.h #define M 16 typedef struct char num10; int s; STREC; int proc(STREC*a, STREC*b, int 1, int h) void main() STREC stuM=“GA005“, 85, “GA003“, 76, “GA002“, 69, “GA004“, 85, “GA001“, 96, “GA007“, 72, “GA008“, 64, “GA006“, 87, “GA015“, 85, “GA013“, 94, “GA012“,

6、 64, “GA014“, 91, “GA011“, 90, “GA017“, 64, “GA0t8“, 64, “GA016“, 72; STREC hM; int i, n, low, heigh, t; printf(“Enter 2 integer number low scanf(“%d%d“, if(heighlow) t=heigh; heigh=low; low=t; n=proc(stu, h, low, heigh); printf(“The student“s data between %d-%d:/n“, low, heigh); for(i=0; in; i+) pr

7、intf(“%s%4d/n“, hi.num, hi.s); /输出指定分数范围内的学生记录 printf(“/n“); (分数:30.00)_二级 C 语言-312 (1)答案解析(总分:100.00,做题时间:90 分钟)一、程序填空题(总题数:1,分数:30.00)1.请补充 main()函数,该函数的功能是:输出一个 44 的矩阵,要求必须使用行指针表示输出变量。 注意:部分源程序给出如下。 请勿改动 main()函数和其他函数中的任何内容,仅在 main()函数的横线上填入所编写的若干表达式或语句。 试题程序: #includestdlib.h #includestdio.h voi

8、d main() static int art44=9, 8, 7, 6, 6, 5, 4, 3, 3, 2, 1, 0, 2, 4, 6, 8; int(*p)4, j, i; p= 1; system(“CLS“); for(i=0; i4; i+) printf(“/n/n“); for(j=0; j4; j+) printf(“%4d“, 2); (分数:30.00)解析:arr *(*(p+i)+j)解析 题目中要求必须使用行指针表示输出变量,由程序可知变量 p 为行指针,其应该初始化为数组的首地址,因此第一处应填“arr”;每输出一个数组元素时,变量 p 为上一行的朱地址加上该行的

9、偏移量,因此第二处填“*(*(p+i)+j)”。二、程序改错题(总题数:1,分数:40.00)2.下列给定程序中,函数 proc()的功能是:依次取出字符串中所有的数字字符,形成新的字符串,并取代原字符串。例如原始字符串是“ab45c6djfd789”,则输出后的字符是“456789”。 请修改函数 proc()中的错误,使它能得出正确的结果。 注意:不要改动 main()函数,不得增行或删行,也不得更改程序的结构。 试题程序: #includestdlib.h #includestdio.h #includeconio.h void proc(char*s) int i, j; for(i=

10、0, j=0; si!=“/0“; i+) if(si=“0“ /*found* sj=“/0“; void main() char str80; system(“CLS“); printf(“/nEnter a string:“); gets(str); printf(“/n/nThe string is:%s/n“, str); proc(str); printf(“/n/nThe siring of changing is: %s/n“, str); (分数:40.00)_正确答案:()解析:(1)错误:sj=si 正确:sj+=si (2)错误:sj=“/0“; 正确:sj=“/0“;

11、 解析 题目要求将字符串中的数字字符形成新字符串并取代原字符串,每检查到一个数字字符,将其放在原字符串下标为 0 处开始存放,下标加 1,因此“sj=si”应改为“sj+=si”。要使数字字符串成为独立的字符串,应该在数字字符串末尾加上结束符,字符串的结束符为“/0“,因此“sj=“/0“”应改为“sj=“/0“”。三、程序设计题(总题数:1,分数:30.00)3.学生的记录由学号和成绩组成,M 名学生的数据已在主函数中放入结构体数组 stu 中,请编写函数proc(),它的功能是:把指定分数范围内的学生数据放在 b 所指的数组中,分数范围内的学生人数由函数值返回。 例如,输入的分数是 707

12、9,则应当把分数在 7079 的学生数据进行输出,包含 70 分和 79 分的学生数据。主函数中把 70 放在 low 中,把 79 放在 heigh 中。 注意:部分源程序给出如下。 请勿改动 main()函数和其他函数中的任何内容,仅在函数 proc 的花括号中填入所编写的若干语句。 试题程序: #includestdio.h #define M 16 typedef struct char num10; int s; STREC; int proc(STREC*a, STREC*b, int 1, int h) void main() STREC stuM=“GA005“, 85, “G

13、A003“, 76, “GA002“, 69, “GA004“, 85, “GA001“, 96, “GA007“, 72, “GA008“, 64, “GA006“, 87, “GA015“, 85, “GA013“, 94, “GA012“, 64, “GA014“, 91, “GA011“, 90, “GA017“, 64, “GA0t8“, 64, “GA016“, 72; STREC hM; int i, n, low, heigh, t; printf(“Enter 2 integer number low scanf(“%d%d“, if(heighlow) t=heigh; h

14、eigh=low; low=t; n=proc(stu, h, low, heigh); printf(“The student“s data between %d-%d:/n“, low, heigh); for(i=0; in; i+) printf(“%s%4d/n“, hi.num, hi.s); /输出指定分数范围内的学生记录 printf(“/n“); (分数:30.00)_正确答案:()解析:int proc(STREC*a, STREC*b, int 1, int h) int i, j=0; for(i=0; iM; i+) /从第 0 个到第 M-1 个学生开始比较 if(ai.s=1 /把符合条件的学生数据放到 b 结构体中 return j; /最后把学生的个数返回到主函数中 解析 要找出指定分数范围内的学生,就需要将每一个学生的成绩与指定的分数范围相比较,将每一个符合的数据记录放在数组 b 中,最后将符合的学生个数返回到主函数。

展开阅读全文
相关资源
猜你喜欢
  • ETSI EN 302 054-1-2015 Meteorological Aids (Met Aids) Radiosondes to be used in the 400 15 MHz to 406 MHz frequency range with power levels ranging up to 200 mW Part 1 Technical ch_1.pdf ETSI EN 302 054-1-2015 Meteorological Aids (Met Aids) Radiosondes to be used in the 400 15 MHz to 406 MHz frequency range with power levels ranging up to 200 mW Part 1 Technical ch_1.pdf
  • ETSI EN 302 054-2-2015 Meteorological Aids (Met Aids) Radiosondes to be used in the 400 15 MHz to 406 MHz frequency range with power levels ranging up to 200 mW Part 2 Harmonised S.pdf ETSI EN 302 054-2-2015 Meteorological Aids (Met Aids) Radiosondes to be used in the 400 15 MHz to 406 MHz frequency range with power levels ranging up to 200 mW Part 2 Harmonised S.pdf
  • ETSI EN 302 054-2-2015 Meteorological Aids (Met Aids) Radiosondes to be used in the 400 15 MHz to 406 MHz frequency range with power levels ranging up to 200 mW Part 2 Harmonised S_1.pdf ETSI EN 302 054-2-2015 Meteorological Aids (Met Aids) Radiosondes to be used in the 400 15 MHz to 406 MHz frequency range with power levels ranging up to 200 mW Part 2 Harmonised S_1.pdf
  • ETSI EN 302 054-2017 Meteorological Aids (Met Aids) Radiosondes to be used in the 400 15 MHz to 406 MHz frequency range with power levels ranging up to 200 mW Harmonised Standard c.pdf ETSI EN 302 054-2017 Meteorological Aids (Met Aids) Radiosondes to be used in the 400 15 MHz to 406 MHz frequency range with power levels ranging up to 200 mW Harmonised Standard c.pdf
  • ETSI EN 302 054-2018 Meteorological Aids (Met Aids) Radiosondes to be used in the 400 15 MHz to 406 MHz frequency range with power levels ranging up to 200 mW Harmonised Standard c.pdf ETSI EN 302 054-2018 Meteorological Aids (Met Aids) Radiosondes to be used in the 400 15 MHz to 406 MHz frequency range with power levels ranging up to 200 mW Harmonised Standard c.pdf
  • ETSI EN 302 054-2018 Meteorological Aids (Met Aids) Radiosondes to be used in the 400 15 MHz to 406 MHz frequency range with power levels ranging up to 200 mW Harmonised Standard c_1.pdf ETSI EN 302 054-2018 Meteorological Aids (Met Aids) Radiosondes to be used in the 400 15 MHz to 406 MHz frequency range with power levels ranging up to 200 mW Harmonised Standard c_1.pdf
  • ETSI EN 302 062-2003 Fixed Radio Systems Point-to-Point Equipment High Capacity Digital Radio Relay Systems Carrying STM-4 4 x STM-1 or 2 x STM-1 Signals in Bands with 55 56 MHz Ch.pdf ETSI EN 302 062-2003 Fixed Radio Systems Point-to-Point Equipment High Capacity Digital Radio Relay Systems Carrying STM-4 4 x STM-1 or 2 x STM-1 Signals in Bands with 55 56 MHz Ch.pdf
  • ETSI EN 302 062-2003 Fixed Radio Systems Point-to-Point Equipment High Capacity Digital Radio Relay Systems Carrying STM-4 4 x STM-1 or 2 x STM-1 Signals in Bands with 55 56 MHz Ch_1.pdf ETSI EN 302 062-2003 Fixed Radio Systems Point-to-Point Equipment High Capacity Digital Radio Relay Systems Carrying STM-4 4 x STM-1 or 2 x STM-1 Signals in Bands with 55 56 MHz Ch_1.pdf
  • ETSI EN 302 063-2003 Fixed Radio Systems Multipoint Equipment Multipoint Digital Radio Systems Operating in the 31 0 GHz to 33 4 GHz (32 GHz) Frequency Range (V1 1 1)《固定无线电系统 多点设备 .pdf ETSI EN 302 063-2003 Fixed Radio Systems Multipoint Equipment Multipoint Digital Radio Systems Operating in the 31 0 GHz to 33 4 GHz (32 GHz) Frequency Range (V1 1 1)《固定无线电系统 多点设备 .pdf
  • 相关搜索

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

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