欢迎来到麦多课文档分享! | 帮助中心 海量文档,免费浏览,给你所需,享你所想!
麦多课文档分享
全部分类
  • 标准规范>
  • 教学课件>
  • 考试资料>
  • 办公文档>
  • 学术论文>
  • 行业资料>
  • 易语言源码>
  • ImageVerifierCode 换一换
    首页 麦多课文档分享 > 资源分类 > DOC文档下载
    分享到微信 分享到微博 分享到QQ空间

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

    • 资源ID:1329701       资源大小:35.50KB        全文页数:9页
    • 资源格式: DOC        下载积分:5000积分
    快捷下载 游客一键下载
    账号登录下载
    微信登录下载
    二维码
    微信扫一扫登录
    下载资源需要5000积分(如需开发票,请勿充值!)
    邮箱/手机:
    温馨提示:
    如需开发票,请勿充值!快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如需开发票,请勿充值!如填写123,账号就是123,密码也是123。
    支付方式: 支付宝扫码支付    微信扫码支付   
    验证码:   换一换

    加入VIP,交流精品资源
     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    【计算机类职业资格】全国计算机等级考试二级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;)解析:解析 用指针遍历第一个字符串,把指针定位到串尾标志符处;遍历第二个字符串,依次把字符复制到第一个字符串的末尾;最后赋结尾标志符。


    注意事项

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




    关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

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

    收起
    展开