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

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

1、国家二级 C语言机试(操作题)模拟试卷 136及答案与解析 一、程序填空题 1 fun的功能是进行数字字符转换。若形参 ch中是数字字符 0 9,则 0转换成9, 1转换成 8, 2转换成 7, , 9转换成 0;若是其他字符则保持不变;并将转换后的结果作为函数值返回。 请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。 注意:源程序存放在考生文件夹下的 BLANK1 C中。 不得增行或删行,也不得更改程序的结构 ! #include *found* _1_fun(char ch) *found* if(ch=0 _2_) *found* return 9-(ch-_3_)

2、j return ch; main() char c1, c2; printf(“ nThe result: n“); c1=2; c2=fun(c1); printf(“c1= c c2= c n“, c1, c2); c1=8; c2=fun(c1); printf(“c1= c c2= c n“, c1, c2); c1=a; c2=fun(c1); printf(“c1= c c2= c n“, c1, c2); 二、程序修改题 2 给定程序 MODI1 C中函数 fun的功能是:将 P所指字符串中的所有字符复制到 b中,要求每复制三个字符之后插入一个空格。 例如,在调用 fun函数之

3、前给 a输入字符串: ABCDEFGHUK,调用函数之 后,字符数组 b中的内容则为: ABC DEF GHI JK。 请改正程序中的错误,使它能得出正确结果。 注意:不要改动 main函数,不得增行或删行,也不得更改程序的结构。 #include void fun(char *P, char *b) int i, k=0; while(*P) i=1; while(i #include #define N 8 struct slist double s; struct sliSt *next; typedef struct slist STREC; double fun(STREC *h)

4、STREC *creat(double *s) STREC *h, *P, *q; int i=0; h=p=(STREC*)malloc(sizeof(STREC); P-s=0; while(is=si; i+; P-next=q; P=q; P-next=0; return h; outlist(STREC *h) STREC *P; p=h-next; printf(“head“); do printf(“- 4 1f“, P-s); P=P- next; while(P!=0); printf(“ n n“); main() double sN=85, 7 6, 69, 85, 91

5、 72, 64, 87, ave; void NONO(); STREC *h; h=creat(s); outlist(h); ave=fun(h); printf(“ave= 6 3f n“, ave); NONO(); void NONO() *本函数用于打开文件,输入数据,调用函数,输出数据,关闭文件。 * FILE *in, *out; int i, j; double sN, ave; STREC *h; in=fopen(“in dat“, “r“); out=fopen(“out dat“, “w“); for(i=0;、 i=0且 chnext; *由于头结点中没有存放数据 * double av=0 0; *对计算成绩平均值的变量进行初始化 * int n=0; while(p!=NULL) *判断链表是否结束 * av=av+p-s; *对成绩进行累加 * p=p-next; *到下一个结点位置 * n+; *人数加 1* av =n; *计算成绩平均值 * return av; *返回成绩平均值 * 【试题解析】 (1)首先 定义存放平均值的变量,并对其初始化。 (2)在循环中,依次取链表中存放的成绩,并对其求和。 (3)最后计算平均佰,并返回值。

展开阅读全文
相关资源
猜你喜欢
  • 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