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

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

1、国家二级 C语言机试(操作题)模拟试卷 67及答案与解析 一、程序填空题 1 程序通过定义学生结构体变量,存储了学生的学号、姓名和 3门课的成绩。所有学生数据均以二进制方式输出到文件中。函数 fun的功能是重写形参 filename所指文件中最后一个学生的数据,即用新的学生数据覆盖该学生原来的数据,其他学生的数据不变。 请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。 注意:源程序存放在考生文件夹下的 BLANKl C中。 不得增行或删行,也不得更改程序的结构 ! #include #defitie N 5 typedef struct student long sno;

2、 char name10; float Score3; STU; void fun(char*filename, STU n) FILE*fp; /*found*/ fp=fopen( _1_ , “rb+“); /*found*/ fseek(_2_, 一 (long)sizeof(STU), SEEK END); /*found*/ fwrite(&n, sizeof(STU), 1, _3_ ); fclose(fp); main() STU tN=1000l, “Machao“, 91, 92, 77), 10002, “CaoKai“, 75, 60, 8 8), 10003, “L

3、iSi“, 85, 70, 78), 10004, “FangFang“, 90, 82, 87), 1 00 0 5, “ZhangSan“, 95, 8 0, 8 8; STU n=1 0 0 0 6, “7,haoSi“, 55, 70, 68, ssN; int i, j; FILE*fp; fp=fopen(“Student dat“, “wb“); fwrite(t, Sizeof(STU), N, fp); fciose(fp); fp=fopen(“student dat“, “rb“); fread(ss, sizeof(STU), N, fp); fclose(fp); p

4、rintf(“nThe original data: nn“); for(j=0; j #include typedef struct aa int data ; struct aa*next; )NODE; NODE*CreatIink(int n, int m) NODE*h=NULL, *p, *s; int i; /*found*/ p=(NODE)malloc(sizeof(NODE); h=P; P-next=NULL; for(i=1; idata=rand() mj s-next=p- next; P-next=s; p=p-next; /*found*/ return p;

5、outlink(NODE*h) NODE*p; p: h-next ; printf(“nnTHE LIST: nn HEAD“); while(P) printf(“- d“, P-data); p=p-next; printf(“n“); main() NODE*head; head=Creatlink(8, 22); outlink(head); 三、程序设计题 3 请编写函数 fun,函数的功能是:统计一行字符串中单词的个数,作为函数值返回。一行字符串在主函数中输入,规定所有单词由小写字母组成,单词之间由若干个空格隔开一行的开始没有空格。 注意:部分源程序在文件 PROGl C中。 请

6、勿改动主函数 main和其他函数中的任何内容,仅在函数 fun的花括号中填入你编写的若干语句。 #include #include #define N 8 0 int fun(char*s) main() char lineN; int num=0; voidNONO(); printf(“Enter a string : n“); gets(line); num=fun(lime); printf(“The number of word is: dnn“, num); NONO(); void NONO() /*请在此函数内打开文件,输入测试数据, 调用 fun函数,输出数据,关闭文件。 */ FILE*rf, *wf ; int i, num ; char 1ineN, *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 ISO 8178-9-2012 Reciprocating internal combustion engines Exhaust emission measurement Test cycles and test procedures for test bed measurement of exhaust gas smoke emi.pdf BS ISO 8178-9-2012 Reciprocating internal combustion engines Exhaust emission measurement Test cycles and test procedures for test bed measurement of exhaust gas smoke emi.pdf
  • BS ISO 8179-1-2017 Ductile iron pipes fittings accessories and their joints External zinc-based coating Metallic zinc with finishing layer《球墨铸铁管、管件、附件及其接头 外部镀锌 第1部分 终饰层用金属.pdf BS ISO 8179-1-2017 Ductile iron pipes fittings accessories and their joints External zinc-based coating Metallic zinc with finishing layer《球墨铸铁管、管件、附件及其接头 外部镀锌 第1部分 终饰层用金属.pdf
  • BS ISO 8179-2-2017 Ductile iron pipes fittings accessories and their joints - External zinc-based coating Part 2 Zinc-rich paint《球墨铸铁管、配件、附件及其接头-外部锌基涂层 2部分 富锌涂料》.pdf BS ISO 8179-2-2017 Ductile iron pipes fittings accessories and their joints - External zinc-based coating Part 2 Zinc-rich paint《球墨铸铁管、配件、附件及其接头-外部锌基涂层 2部分 富锌涂料》.pdf
  • BS ISO 8188-2007 Textile machinery and accessories - Pitches of knitting machines《纺织机械与附件 针织机针距》.pdf BS ISO 8188-2007 Textile machinery and accessories - Pitches of knitting machines《纺织机械与附件 针织机针距》.pdf
  • BS ISO 8196-1-2009 Milk - Definition and evaluation of the overall accuracy of alternative methods of milk analysis - Analytical attributes of alternative methods《牛乳 牛乳分析变.pdf BS ISO 8196-1-2009 Milk - Definition and evaluation of the overall accuracy of alternative methods of milk analysis - Analytical attributes of alternative methods《牛乳 牛乳分析变.pdf
  • BS ISO 8196-2-2009 Milk - Definition and evaluation of the overall accuracy of alternative methods of milk analysis - Calibration and quality control in the dairy laborato.pdf BS ISO 8196-2-2009 Milk - Definition and evaluation of the overall accuracy of alternative methods of milk analysis - Calibration and quality control in the dairy laborato.pdf
  • BS ISO 8196-3-2009 Milk - Definition and evaluation of the overall accuracy of alternative methods of milk analysis - Protocol for the evaluation and validation of alterna.pdf BS ISO 8196-3-2009 Milk - Definition and evaluation of the overall accuracy of alternative methods of milk analysis - Protocol for the evaluation and validation of alterna.pdf
  • BS ISO 8216-1-2017 Petroleum products Fuels (class F) classification Categories of marine fuels《石油产品 燃料(F类)分类 船用燃料类别》.pdf BS ISO 8216-1-2017 Petroleum products Fuels (class F) classification Categories of marine fuels《石油产品 燃料(F类)分类 船用燃料类别》.pdf
  • BS ISO 8216-99-2002 Petroleum products - Fuels (class F) - Classification - General《石油产品 燃料(F级) 分类 总则》.pdf BS ISO 8216-99-2002 Petroleum products - Fuels (class F) - Classification - General《石油产品 燃料(F级) 分类 总则》.pdf
  • 相关搜索

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

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