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

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

1、国家二级 C语言机试(操作题)模拟试卷 507及答案与解析 一、程序填空题 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 return ch ; main (

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

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

4、at(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.If“,p-s);p=p- next; while(p!=0); printf(“nn“)/ main () double sN = 85,76,69,85,91, 72, 64,87 ,ave;

5、 void NONO (); STREC *h; h=creat(s); outlist(h); ave=fun(h); printf(“ave= %6.3fn“,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)最后计算平均值,并返回值。

展开阅读全文
相关资源
猜你喜欢
  • ASHRAE NA-04-8-1-2004 Evaluation of Moisture Buffer Effects by Performing Whole-Building Simulations《整体建筑模拟的水分缓冲效果的表演的评价》.pdf ASHRAE NA-04-8-1-2004 Evaluation of Moisture Buffer Effects by Performing Whole-Building Simulations《整体建筑模拟的水分缓冲效果的表演的评价》.pdf
  • ASHRAE NA-04-8-2-2004 Effect of Moisture on Hygrothermal and Energy Performance of a Building with Cellular Concrete Walls in Climatic Conditions of Poland《在波兰的气候条件下 一个建筑物蜂窝混凝土墙的水分.pdf ASHRAE NA-04-8-2-2004 Effect of Moisture on Hygrothermal and Energy Performance of a Building with Cellular Concrete Walls in Climatic Conditions of Poland《在波兰的气候条件下 一个建筑物蜂窝混凝土墙的水分.pdf
  • ASHRAE NA-04-8-2004 Symposium on Modeling Moisture Sorption Desorption by Building Matierials《建模水分吸着 解吸建设材料的研讨会上》.pdf ASHRAE NA-04-8-2004 Symposium on Modeling Moisture Sorption Desorption by Building Matierials《建模水分吸着 解吸建设材料的研讨会上》.pdf
  • ASHRAE NA-04-8-3-2004 Moderating Indoor Conditions with Hygroscopic Building Materials and Outdoor Ventilation《吸湿建材及户外通风对室内条件缓和》.pdf ASHRAE NA-04-8-3-2004 Moderating Indoor Conditions with Hygroscopic Building Materials and Outdoor Ventilation《吸湿建材及户外通风对室内条件缓和》.pdf
  • ASHRAE NA-04-8-4-2004 Predicting Indoor Temperature and Humidity Conditions Including Hygrothermal Interactions with the Building Envelope《室内温度和湿度条件的预测 包括湿热互动与建筑围护结构》.pdf ASHRAE NA-04-8-4-2004 Predicting Indoor Temperature and Humidity Conditions Including Hygrothermal Interactions with the Building Envelope《室内温度和湿度条件的预测 包括湿热互动与建筑围护结构》.pdf
  • ASHRAE NA-04-9-1-2004 Application of Conduction Transfer Functions and Periodic Response Factors in Cooling Load Calculation Procedures《传导传递函数和在冷负荷计算程序中的周期响应因子的应用》.pdf ASHRAE NA-04-9-1-2004 Application of Conduction Transfer Functions and Periodic Response Factors in Cooling Load Calculation Procedures《传导传递函数和在冷负荷计算程序中的周期响应因子的应用》.pdf
  • ASHRAE NA-04-9-2004 Symposium on Load Calculations《负荷计算的研讨会》.pdf ASHRAE NA-04-9-2004 Symposium on Load Calculations《负荷计算的研讨会》.pdf
  • ASHRAE NA-04-9-2A-2004 Heat Loss from Electrical and Control Equipment in Industrial Plants Part 1 - Methods and Scope (RP-1104)《在工业厂房中的电机及控制设备的热损失 第1部分-方法和范围RP-1104》.pdf ASHRAE NA-04-9-2A-2004 Heat Loss from Electrical and Control Equipment in Industrial Plants Part 1 - Methods and Scope (RP-1104)《在工业厂房中的电机及控制设备的热损失 第1部分-方法和范围RP-1104》.pdf
  • ASHRAE NA-04-9-2B-2004 Heat Loss from Electrical and Control Equipment in Industrial Plants Part II - Results and Comparisons《在工业厂房中的电机及控制设备的热损失 第2部分-结果并进行比较反相RP-1104》.pdf ASHRAE NA-04-9-2B-2004 Heat Loss from Electrical and Control Equipment in Industrial Plants Part II - Results and Comparisons《在工业厂房中的电机及控制设备的热损失 第2部分-结果并进行比较反相RP-1104》.pdf
  • 相关搜索

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

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