ImageVerifierCode 换一换
格式:DOC , 页数:9 ,大小:35.50KB ,
资源ID:1329701      下载积分:5000 积分
快捷下载
登录下载
邮箱/手机:
温馨提示:
如需开发票,请勿充值!快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝扫码支付 微信扫码支付   
注意:如需开发票,请勿充值!
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【http://www.mydoc123.com/d-1329701.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(【计算机类职业资格】全国计算机等级考试二级C语言机试真题2010年3月及答案解析.doc)为本站会员(wealthynice100)主动上传,麦多课文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知麦多课文库(发送邮件至master@mydoc123.com或直接QQ联系客服),我们立即给予删除!

【计算机类职业资格】全国计算机等级考试二级C语言机试真题2010年3月及答案解析.doc

1、全国计算机等级考试二级 C 语言机试真题 2010 年 3 月及答案解析(总分:100.00,做题时间:90 分钟)一、程序填空题(总题数:1,分数:30.00)1.给定程序中已建立一个带有头结点的单向链表,在 main 函数中将多次调用 fun 函数,每调用一次 fun函数,输出链表尾部结点中的数据,并释放该结点,使链表缩短。注意 部分源程序给出如下。请勿改动主函数 main 和其他函数中的任何内容,仅在函数 fun 的横线上填入所编写的若干表达式或语句。试题源程序#includestdio.h#includestdlib.h#define N 8typedef struct listint

2、 data;struct list *next;SLIST;void fun(SLIST *p)SLIST *t, *s;t=P-next;s=p;while(t-next!=NULL)s=t;/*found*/t=t- (1) ;/*found*/printf(”%d”, (2) );s-next=NULL:/*found*/free( (3) );SLIST *creatlist(int *a)SLIST *h, *p, *q;int i;h=p=(SLIST *)malloc(sizeof(SLIST);for(i=0; iN; i+)q=(SLIST *)malloc(sizeof(S

3、LIST);q-data=ai;p-next=q;p=q;P-next=0;return h;void outlist(SLIST *h)SLIST *p;p=h-next;if(p=NULL)printf(“/nThe list is NULL!/n“);elseprintf(“/nHead“);doprintf(“-%d“, P-data);p=p-next;while(P!=NULL);printf(“-End/n“);main()SLIST *head;int aN=(11, 12, 15, 18, 19, 22, 25, 29);head=creatlist(a);printf(“/

4、nOutput from head:/n“);outlist(head);printf(“/nOutput from tail:/n“);while(head-next!=NULL)fun(head);printf(“/n/n“);printf (“/nOutput from head again:/n“);outlist(head);(分数:30.00)填空项 1:_二、程序修改(总题数:1,分数:30.00)2.给定程序中函数 fun 的功能是:将一个由八进制数字字符组成的字符串转换为与其值相等的十进制整数。规定输入的字符串最多只能包含 5 位八进制数字字符。例如,若输入:77777,则输

5、出将是:32767。请改正程序中的错误,使它能得到正确结果。注意 不要改动 main 函数,不得增行或删行,也不得更改程序的结构。试题源程序#includestdio.h#includestring.h#includestdlib.hint fun(char *p)int n;/*found*/n=*p-o;p+;while(*p!=0)/*found*/n=n*8+*p-o;p+;return n;main()char s6; int i; int n;printf(“Enter a string(Ocatal digits):“);gets(s);if(strlen(s)5)printf(

6、Error: String too longer!/n/n“);exit(0);for(i=0; si; i+)if(si0|si7)printf(“Error: %c not is ocatal digits!/n/n“, si);exit(0);printf(“The original string:“);puts(s);n=fun(s);printf(“/n%s iS convered to integer number: %d/n/n“, s, n);(分数:30.00)_三、程序设计(总题数:1,分数:40.00)3.请编写函数 fun(),它的功能是:实现两个字符串的连接(不使用

7、库函数 strcat(),即把 p2 所指的字符串连接到 p1 所指的字符串后。例如,分别输入下面两个字符串:FirstString-SecondString则程序输出:FirstString-SecondString注意 部分源程序给出如下。请勿改动主函数 main 和其他函数中的任何内容,仅在函数 fun 的花括号中填入所编写的若干语句。试题源程序#includestdio.h#includeconio.hvoid fun(char p1, char p2)main()char s180, s240;clrscr();printf(“Enter s1 and s2:/n“);scanf(“

8、s%s“, s1, s2);printf(“s1=%s/n“, s1);printf(“s2=%s/n“, s2);printf(“Invoke fun(s1, s2):/n“);fun(s1, s2);printf(“After invoking:/n“);printf(“%s/n“, s1);(分数:40.00)_全国计算机等级考试二级 C 语言机试真题 2010 年 3 月答案解析(总分:100.00,做题时间:90 分钟)一、程序填空题(总题数:1,分数:30.00)1.给定程序中已建立一个带有头结点的单向链表,在 main 函数中将多次调用 fun 函数,每调用一次 fun函数,输

9、出链表尾部结点中的数据,并释放该结点,使链表缩短。注意 部分源程序给出如下。请勿改动主函数 main 和其他函数中的任何内容,仅在函数 fun 的横线上填入所编写的若干表达式或语句。试题源程序#includestdio.h#includestdlib.h#define N 8typedef struct listint data;struct list *next;SLIST;void fun(SLIST *p)SLIST *t, *s;t=P-next;s=p;while(t-next!=NULL)s=t;/*found*/t=t- (1) ;/*found*/printf(”%d”, (2

10、) );s-next=NULL:/*found*/free( (3) );SLIST *creatlist(int *a)SLIST *h, *p, *q;int i;h=p=(SLIST *)malloc(sizeof(SLIST);for(i=0; iN; i+)q=(SLIST *)malloc(sizeof(SLIST);q-data=ai;p-next=q;p=q;P-next=0;return h;void outlist(SLIST *h)SLIST *p;p=h-next;if(p=NULL)printf(“/nThe list is NULL!/n“);elseprintf(

11、/nHead“);doprintf(“-%d“, P-data);p=p-next;while(P!=NULL);printf(“-End/n“);main()SLIST *head;int aN=(11, 12, 15, 18, 19, 22, 25, 29);head=creatlist(a);printf(“/nOutput from head:/n“);outlist(head);printf(“/nOutput from tail:/n“);while(head-next!=NULL)fun(head);printf(“/n/n“);printf (“/nOutput from h

12、ead again:/n“);outlist(head);(分数:30.00)填空项 1:_ (正确答案:1 next2 t-data3 t)解析:解析 填空 1:要求输出链表尾部的数据,函数利用 while 循环语句找出链表尾部的指针并存入临时变量 s 中,即每循环一次就要判断链表是否已结束位置,如果是,则退出循环,进行输出,由于是通过 t 指针变量进行操作的,因此,都要取 t 的 next 指针重新赋给 t 来实现,所以本处应填 next。填空 2:输出最后一个结点的数据,所以应填 t-data 或(*t).data。填空 3:输出最后一个结点的数据后,并把此结点删除,程序要求释放内存,故

13、应填 t。二、程序修改(总题数:1,分数:30.00)2.给定程序中函数 fun 的功能是:将一个由八进制数字字符组成的字符串转换为与其值相等的十进制整数。规定输入的字符串最多只能包含 5 位八进制数字字符。例如,若输入:77777,则输出将是:32767。请改正程序中的错误,使它能得到正确结果。注意 不要改动 main 函数,不得增行或删行,也不得更改程序的结构。试题源程序#includestdio.h#includestring.h#includestdlib.hint fun(char *p)int n;/*found*/n=*p-o;p+;while(*p!=0)/*found*/n=

14、n*8+*p-o;p+;return n;main()char s6; int i; int n;printf(“Enter a string(Ocatal digits):“);gets(s);if(strlen(s)5)printf(“Error: String too longer!/n/n“);exit(0);for(i=0; si; i+)if(si0|si7)printf(“Error: %c not is ocatal digits!/n/n“, si);exit(0);printf(“The original string:“);puts(s);n=fun(s);printf(

15、/n%s iS convered to integer number: %d/n/n“, s, n);(分数:30.00)_正确答案:(1)错误:*p正确:*p(2)错误:o;正确:o;)解析:解析 错误 1:函数的形参用的是小写 p,而函数中调用参数时用了大写 p, *p 错写成了*p。错误 2:编译后可知,o错写成了o。三、程序设计(总题数:1,分数:40.00)3.请编写函数 fun(),它的功能是:实现两个字符串的连接(不使用库函数 strcat(),即把 p2 所指的字符串连接到 p1 所指的字符串后。例如,分别输入下面两个字符串:FirstString-SecondString则

16、程序输出:FirstString-SecondString注意 部分源程序给出如下。请勿改动主函数 main 和其他函数中的任何内容,仅在函数 fun 的花括号中填入所编写的若干语句。试题源程序#includestdio.h#includeconio.hvoid fun(char p1, char p2)main()char s180, s240;clrscr();printf(“Enter s1 and s2:/n“);scanf(“%s%s“, s1, s2);printf(“s1=%s/n“, s1);printf(“s2=%s/n“, s2);printf(“Invoke fun(s1, s2):/n“);fun(s1, s2);printf(“After invoking:/n“);printf(“%s/n“, s1);(分数:40.00)_正确答案:(void fun(char p1, char p2)int i=0, n=0;char *p=p1, *q=p2;while(*p)p+;n+;i=n;while(*q)p1i=*q;q+;i+;p1i=/0;)解析:解析 用指针遍历第一个字符串,把指针定位到串尾标志符处;遍历第二个字符串,依次把字符复制到第一个字符串的末尾;最后赋结尾标志符。

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