[计算机类试卷]国家二级C语言机试(操作题)模拟试卷160及答案与解析.doc

上传人:priceawful190 文档编号:498080 上传时间:2018-11-28 格式:DOC 页数:6 大小:32KB
下载 相关 举报
[计算机类试卷]国家二级C语言机试(操作题)模拟试卷160及答案与解析.doc_第1页
第1页 / 共6页
[计算机类试卷]国家二级C语言机试(操作题)模拟试卷160及答案与解析.doc_第2页
第2页 / 共6页
[计算机类试卷]国家二级C语言机试(操作题)模拟试卷160及答案与解析.doc_第3页
第3页 / 共6页
[计算机类试卷]国家二级C语言机试(操作题)模拟试卷160及答案与解析.doc_第4页
第4页 / 共6页
[计算机类试卷]国家二级C语言机试(操作题)模拟试卷160及答案与解析.doc_第5页
第5页 / 共6页
点击查看更多>>
资源描述

1、国家二级 C语言机试(操作题)模拟试卷 160及答案与解析 一、程序填空题 1 给定程序中,函数 fun的功能是将不带头结点的单向链表逆置。即若原链表中从头至尾结点数据域依次为: 2、 4、 6、 8、 10,逆置后,从头至尾结点数据域依次为: 10、 8、 6、 4、 2。 请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。 注意:源程序存放在考生文件夹下的 BLANKl C中。 不得增行或删行,也不得更改程序的结构 ! #include #inciude #defime N 5 typedef struct node int data; struct node*next

2、 ; NODE ; *found* _1_ fun(NODE*h) NODE*p, *q, *r; p=h ; if(p=NULL) return NULL; q=p-next; p-next=NULL; while(q) *found* r=q-_2_; q-next=p; p=q; *found* q=_3_; return p; NODE *creatlist(int a) NODE *h, *p, *q; int i; h=NULL; for(i=0; idata=ai; q-next=NULL; if(h=NULL)h=p=q; elsep-next=q; p=q; return h

3、 void outiist(NODE*h) NODE *p; p=h; if(p=NULL)printf(“The list is NULL! n“); else printf(“ nHead“); do printf(“- d“, p-data); p=p -next; while(p!=NULL); printf(“-End n“); msin() NODE *head; int aN=2, 4, 6, 8, 10; head=creatlist(a); printf(“ nThe original list: n“); outlist(head); head=fun(head); pr

4、intf(“ nThe list after inverting: n“); outlist(head); 二、程序修改题 2 给定程序 MODIl C中函数 fun的功能是:计算函数 (x, y, z)=(x+y) (xy)+(z+y) (z-y)的值。其中 x和 y的值不等, z和 y的值不等。 例如,当 x的值为 9、 y的值为 11、 z的值为 15时,函数值为一 3 50。 请改正程序中的错误,使它能得出正确结果。 注意:不要改动 main函数,不得增行或删行,也不得更改程序的结构。 #include #include #include *found* #define FU(m, n

5、) (m n) float fun(float a, float b, fIoat c) float valme; value=FU(a+b, a b)+FU(c+b, c b); *found* Return(Valme); main() float x, y, z, sum; printf(“Input x y z: “); scanf(“ f f f“, x, y, z); printf(“x= f, y= f, z= f n“, x, y, z); if(x=y y=z)printf(“Data error! n“); exit(0); sum=fun(x, y, z); printf

6、The result is: 5 2 f n“, sum); 三、程序设计题 3 请编写函数 fun,函数的功能是:统计一行字符串中单词的个数,作为函数值返回。一行字符串在主函数中输入,规定所有单词由小写字母组成,单词之间由若干个空格隔开,一行的开始没有空格。 注意:部分源程序在文件 PROGl C中。 请勿改动主函数 main和其他函数中的任何内容, 仅在函数 fun的花括号中填入你编写的若干语句。 #innclude #include #define N 80 int fun(char *s) main() char lineN; int num=0; voidNONO(); prin

7、tf(“Enter a string : n“); gets(line); num=fun(line); printf(“The number of word is: d n n“, num); NONO(); void NONO() *请在此函数内打开文件,输入测试数据,调用 fun函数,输出数据,关闭文件。 * FTLE *rf, *wf; int i, num; char lineN, *p; rf=fopen(“in dat“, “r“); wf=fopen(“out dat“, “w“); for(i=0; i=a si=z si+1 = si+1= 0)单词判断条件 n+; 单词统计计数器加 1 return n; 返回统计值 【试题解析】 (1)首先,求得字符串的长度。 (2)只要小于字符串的长度,就刘 字符进行循环判断。 (3)根据题下要求,只要字符是小写字母,并且下一个紧靠的字符是空格或者尾符,那么单词统计计数器就加 1。

展开阅读全文
相关资源
猜你喜欢
  • BS PD IEC TS 62763-2013_5284 Pilot function through a control pilot circuit using PWM (pulse width modulation) and a control pilot wire《通过控制导向线使用PWM (脉冲宽度调制) 的导向功能和控制导向线》.pdf BS PD IEC TS 62763-2013_5284 Pilot function through a control pilot circuit using PWM (pulse width modulation) and a control pilot wire《通过控制导向线使用PWM (脉冲宽度调制) 的导向功能和控制导向线》.pdf
  • BS ISO 8070-2007 Milk and milk products - Determination of calcium sodium potassium and magnesium contents - Atomic absorption spectrometric method《牛奶和奶制品 钙、钠、钾和镁含量的测定 原子吸.pdf BS ISO 8070-2007 Milk and milk products - Determination of calcium sodium potassium and magnesium contents - Atomic absorption spectrometric method《牛奶和奶制品 钙、钠、钾和镁含量的测定 原子吸.pdf
  • BS ISO 8082-1-2009 Self-propelled machinery for forestry - Laboratory tests and performance requirements for roll-over protective structures - General machines《林业用自推进机械 防倾.pdf BS ISO 8082-1-2009 Self-propelled machinery for forestry - Laboratory tests and performance requirements for roll-over protective structures - General machines《林业用自推进机械 防倾.pdf
  • BS ISO 8082-2-2011 Self-propelled machinery for forestry Laboratory tests and performance requirements for roll-over protective structures Machines having a rotating platf.pdf BS ISO 8082-2-2011 Self-propelled machinery for forestry Laboratory tests and performance requirements for roll-over protective structures Machines having a rotating platf.pdf
  • BS ISO 8083-2006 Machinery for forestry - Falling-object protective structures (FOPS) - Laboratory tests and performance requirements《林业机械 落体防护装置(FOPS) 实验室试验和性能要求》.pdf BS ISO 8083-2006 Machinery for forestry - Falling-object protective structures (FOPS) - Laboratory tests and performance requirements《林业机械 落体防护装置(FOPS) 实验室试验和性能要求》.pdf
  • BS ISO 8086-2004 Dairy plant - Hygiene conditions - General guidance on inspection and sampling procedures《乳品厂 卫生条件 检验和取样程序通用指南》.pdf BS ISO 8086-2004 Dairy plant - Hygiene conditions - General guidance on inspection and sampling procedures《乳品厂 卫生条件 检验和取样程序通用指南》.pdf
  • BS ISO 8096-2005 Rubber- or plastics-coated fabrics for water resistant clothing - Specification《雨衣用橡胶或塑料涂覆织物 规范》.pdf BS ISO 8096-2005 Rubber- or plastics-coated fabrics for water resistant clothing - Specification《雨衣用橡胶或塑料涂覆织物 规范》.pdf
  • BS ISO 8097-2001 Aircraft Minimum airworthiness requirements and test conditions for certified air cargo unit load devices《航空器 经认证的航空货运集装单元装置最低适航性要求和试验条件》.pdf BS ISO 8097-2001 Aircraft Minimum airworthiness requirements and test conditions for certified air cargo unit load devices《航空器 经认证的航空货运集装单元装置最低适航性要求和试验条件》.pdf
  • BS ISO 8114-1993 Textile machinery and accessories - Spindles for ring-spinning and doubling machines - List of equivalent terms《纺织机械和附件 环锭纺纱机和并线机用锭子 同义术语表》.pdf BS ISO 8114-1993 Textile machinery and accessories - Spindles for ring-spinning and doubling machines - List of equivalent terms《纺织机械和附件 环锭纺纱机和并线机用锭子 同义术语表》.pdf
  • 相关搜索

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

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