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

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

1、全国计算机二级 C语言上机试题 28+2015年及答案解析(总分:30.00,做题时间:90 分钟)1.给定程序中,函数 fun的功能是:统计形参 s所指字符串中数字字符出现的次数,并存放在形参 t所指的变量中,最后在主函数中输出。例如,形参 s所指的字符串为:abcdef35adgh3kjsdf7。输出结果为:4。 请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。 注意:源程序存放在考生文件夹下的 BLANK1.C中。不得增行或删行,也不得更改程序的结构! 给定源程序: #include void fun(char *s, int *t) int i, n; n=0;

2、/*found*/ for(i=0; _1_ !=NULL; i+) /*found*/ if(si=0 /*found*/ _3_ ; main() char s80=“abcdef35adgh3kjsdf7“; int t; printf(“/nThe original string is : %s/n“,s); fun(s, printf(“/nThe result is : %d/n“,t); (分数:10.00)_正确答案:(第一处:在 for循环中终止值要判断字符串是否结束符,所以应填:si。 第二处:判断是否是数字,所以应填:9。 第三处:字符串中数字字符出现的次数 n,并存放在

3、形参 t所指的变量中,所以应填:*t=n。)解析:2.给定程序 MODI1.C中函数 fun的功能是:通过某种方式实现两个变量值的交换,规定不允许增加语句和表达式。例如变量 a 中的值原为 8,b 中的值原为 3, 程序运行后 a 中的值为 3,b 中的值为 8。 请改正程序中的错误,使它能得出正确的结果。 注意: 不要改动 main 函数,不得增行或删行,也不得更改程序的结构! 给定源程序: #include int fun(int *x,int y) int t ; /*found*/ t = x ; x = y ; /*found*/ return(y) ; main() int a =

4、 3, b = 8 ; printf(“%d %d/n“, a, b) ; b = fun( printf(“%d %d/n“, a, b) ; (分数:10.00)_正确答案:(第一处:由于 x是整型指针变量,所以地址不能赋值给整型变量,因此必须取 x地址上的值,所以应改为 t=*x;*x=y;。 第二处:已交换后的值存放在 t中,所以返回值应为 return(t);。)解析:3.请编写函数 fun,它的功能是: 求出 1 到 1000 之间能被 7 或 11整除、但不能同时被 7 和 11 整除的所有整数并将它们放在 a所指的数组中,通过 n 返回这些数的个数。 注意: 部分源程序在文件

5、PROG1.C中。 请勿改动主函数 main和其它函数中的任何内容,仅在函数 fun的花括号中填入你编写的若干语句。 给定源程序: #include void fun (int *a, int *n) main( ) int aa1000, n, k ; fun ( aa, for ( k = 0 ; k n ; k+ ) if(k + 1) % 10 = 0) printf(“/n“) ; else printf(“, aak) ; NONO( ); (分数:10.00)_正确答案:(void fun (int *a, int *n) int i ; *n = 0 ; for(i = 7 ; i 1000 ; i+) if(i % 7) = 0 | (i % 11) = 0) )解析:

展开阅读全文
相关资源
猜你喜欢
  • ETSI ES 201 660-1999 Terrestrial Trunked Radio (TETRA) Digital Advanced Wireless Service (DAWS) Physical Layer (PHY) Service Description《陆地集群无线电(TETRA) 数字高级无线业务(DAWS) 物理层(PHY)业务描述(.pdf ETSI ES 201 660-1999 Terrestrial Trunked Radio (TETRA) Digital Advanced Wireless Service (DAWS) Physical Layer (PHY) Service Description《陆地集群无线电(TETRA) 数字高级无线业务(DAWS) 物理层(PHY)业务描述(.pdf
  • ETSI ES 201 660-1999 Terrestrial Trunked Radio (TETRA) Digital Advanced Wireless Service (DAWS) Physical Layer (PHY) Service Description《陆地集群无线电(TETRA) 数字高级无线业务(DAWS) 物理层(PHY)业务描述(_1.pdf ETSI ES 201 660-1999 Terrestrial Trunked Radio (TETRA) Digital Advanced Wireless Service (DAWS) Physical Layer (PHY) Service Description《陆地集群无线电(TETRA) 数字高级无线业务(DAWS) 物理层(PHY)业务描述(_1.pdf
  • ETSI ES 201 671-2007 Lawful Interception (LI) Handover interface for the lawful interception of telecommunications traffic (V3 1 1)《通信安全 通信业务流中合法侦听的切换接口(版本3 1 1)》.pdf ETSI ES 201 671-2007 Lawful Interception (LI) Handover interface for the lawful interception of telecommunications traffic (V3 1 1)《通信安全 通信业务流中合法侦听的切换接口(版本3 1 1)》.pdf
  • ETSI ES 201 671-2018 Lawful Interception (LI) Handover interface for the lawful interception of telecommunications traffic (V3 2 1).pdf ETSI ES 201 671-2018 Lawful Interception (LI) Handover interface for the lawful interception of telecommunications traffic (V3 2 1).pdf
  • ETSI ES 201 684-1999 Integrated Services Digital Network (ISDN) File Transfer Profile B-Channel Aggregation and Synchronous Compression (V1 1 1)《综合业务数字网(ISDN) 文件传输模式 B-通道集合和同步压缩(版本.pdf ETSI ES 201 684-1999 Integrated Services Digital Network (ISDN) File Transfer Profile B-Channel Aggregation and Synchronous Compression (V1 1 1)《综合业务数字网(ISDN) 文件传输模式 B-通道集合和同步压缩(版本.pdf
  • ETSI ES 201 684-1999 Integrated Services Digital Network (ISDN) File Transfer Profile B-Channel Aggregation and Synchronous Compression (V1 1 1)《综合业务数字网(ISDN) 文件传输模式 B-通道集合和同步压缩(版本_1.pdf ETSI ES 201 684-1999 Integrated Services Digital Network (ISDN) File Transfer Profile B-Channel Aggregation and Synchronous Compression (V1 1 1)《综合业务数字网(ISDN) 文件传输模式 B-通道集合和同步压缩(版本_1.pdf
  • ETSI ES 201 729-2000 Public Switched Telephone Network (PSTN) 2-Wire Analogue Voice Band Switched Interfaces Timed Break Recall (Register Recall) Specific Requirements for Terminal.pdf ETSI ES 201 729-2000 Public Switched Telephone Network (PSTN) 2-Wire Analogue Voice Band Switched Interfaces Timed Break Recall (Register Recall) Specific Requirements for Terminal.pdf
  • ETSI ES 201 729-2000 Public Switched Telephone Network (PSTN) 2-Wire Analogue Voice Band Switched Interfaces Timed Break Recall (Register Recall) Specific Requirements for Terminal_1.pdf ETSI ES 201 729-2000 Public Switched Telephone Network (PSTN) 2-Wire Analogue Voice Band Switched Interfaces Timed Break Recall (Register Recall) Specific Requirements for Terminal_1.pdf
  • ETSI ES 201 733-2000 Electronic Signature Formats《电子签名格式(版本1 1 3)》.pdf ETSI ES 201 733-2000 Electronic Signature Formats《电子签名格式(版本1 1 3)》.pdf
  • 相关搜索

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

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