[计算机类试卷]国家二级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 ISO 6690-2007 en_2554  Milking machine installations - Mechanical tests《挤奶装置.机械试验》.pdf BS ISO 6690-2007 en_2554 Milking machine installations - Mechanical tests《挤奶装置.机械试验》.pdf
  • BS ISO 6695-2015 en_4938  Cycles Pedal axle and crank assembly with square end fitting Assembly dimensions《自行车.方榫中轴和曲柄的配合.装配尺寸》.pdf BS ISO 6695-2015 en_4938 Cycles Pedal axle and crank assembly with square end fitting Assembly dimensions《自行车.方榫中轴和曲柄的配合.装配尺寸》.pdf
  • BS ISO 6707-3-2017 en_6921  Buildings and civil engineering works Vocabulary Sustainability terms《建筑和土木工程.词汇.可持续性》.pdf BS ISO 6707-3-2017 en_6921 Buildings and civil engineering works Vocabulary Sustainability terms《建筑和土木工程.词汇.可持续性》.pdf
  • BS ISO 6721-10-2015 en_2274  Plastics Determination of dynamic mechanical properties Complex shear viscosity using a parallel-plate oscillatory rheometer《塑料.动态机械性能的测定.使用平板振荡流变仪测定复合剪切粘度》.pdf BS ISO 6721-10-2015 en_2274 Plastics Determination of dynamic mechanical properties Complex shear viscosity using a parallel-plate oscillatory rheometer《塑料.动态机械性能的测定.使用平板振荡流变仪测定复合剪切粘度》.pdf
  • BS ISO 6721-11-2012 en_7322  Plastics Determination of dynamic mechanical properties Glass transition temperature《塑料.动态机械性能的测定.玻璃转换温度》.pdf BS ISO 6721-11-2012 en_7322 Plastics Determination of dynamic mechanical properties Glass transition temperature《塑料.动态机械性能的测定.玻璃转换温度》.pdf
  • BS ISO 6722-1-2011 en_8172  Road vehicles 60 V and 600 V single-core cables Dimensions test methods and requirements for copper conductor cables《道路车辆.60 V和600 V单芯电缆.铜导体电缆的尺寸规格 试验方法和要求》.pdf BS ISO 6722-1-2011 en_8172 Road vehicles 60 V and 600 V single-core cables Dimensions test methods and requirements for copper conductor cables《道路车辆.60 V和600 V单芯电缆.铜导体电缆的尺寸规格 试验方法和要求》.pdf
  • BS ISO 6722-2-2013 en_7108  Road vehicles 60 V and 600 V single-core cables Dimensions test methods and requirements for aluminium conductor cables《道路车辆.60 V和600 V单芯电缆 铝芯电缆的尺寸 试验方法和要求》.pdf BS ISO 6722-2-2013 en_7108 Road vehicles 60 V and 600 V single-core cables Dimensions test methods and requirements for aluminium conductor cables《道路车辆.60 V和600 V单芯电缆 铝芯电缆的尺寸 试验方法和要求》.pdf
  • BS ISO 6727-2012 en_5513  Road vehicles Motorcycles Symbols for controls indicators and tell-tales《道路车辆.摩托车.控制器、指示器和信号装置的符号》.pdf BS ISO 6727-2012 en_5513 Road vehicles Motorcycles Symbols for controls indicators and tell-tales《道路车辆.摩托车.控制器、指示器和信号装置的符号》.pdf
  • BS ISO 6732-2010 en_1228  Milk and milk products - Determination of iron content - Spectrometric method (Reference method)《牛奶和乳制品.铁含量的测定.光谱测定法(基准方法)》.pdf BS ISO 6732-2010 en_1228 Milk and milk products - Determination of iron content - Spectrometric method (Reference method)《牛奶和乳制品.铁含量的测定.光谱测定法(基准方法)》.pdf
  • 相关搜索

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

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