【计算机类职业资格】三级数据库技术-523及答案解析.doc

上传人:王申宇 文档编号:1321187 上传时间:2019-10-17 格式:DOC 页数:3 大小:28.50KB
下载 相关 举报
【计算机类职业资格】三级数据库技术-523及答案解析.doc_第1页
第1页 / 共3页
【计算机类职业资格】三级数据库技术-523及答案解析.doc_第2页
第2页 / 共3页
【计算机类职业资格】三级数据库技术-523及答案解析.doc_第3页
第3页 / 共3页
亲,该文档总共3页,全部预览完了,如果喜欢就下载吧!
资源描述

1、三级数据库技术-523 及答案解析(总分:100.00,做题时间:90 分钟)一、设计与应用题(总题数:1,分数:100.00)1.程序 test.c 的功能是:把 s 字符串中的所有字符左移一个位置,串中的第一个字符移到最后。请考生编写函数 chg(char*s)实现程序要求,最后调用函数 readwriteDAT()把结果输出到 out.dat 文件中。 例如:s 字符串中原有内容为:Mn.123xyZ,则调用该函数后,结果为:n.123xyZM。 请勿改动数据文件 in.dat 中的任何数据、主函数 main()和输出函数 readwriteDAT()的内容。 #include stdi

2、o.h #include string.h #define N 81 /定认宏变量 N, 其值等于 81 void readwriteDAT(); void chg(char *s) main () char a N ; printf(“Enter a string:“); gets(a); printf(“The original string is: “); puts(a); chg (a); printf (“The string after modified:“); puts (a); readwriteDAT (); /*从文件 in.dat 中读入字符串赋给字符串变量 a,调用函数

3、 chg(a)对字符串按照题目的要求进行处理,并把处理结果写入到文件 out.dat 中*/ void readwriteDAT() int i; char a N; FILE *rf, *wf; rf=fopen(“in.dat“, “r“); wf=fopen(“out.dat“, “w“); for(i=0; i10; i+) fscanf (rf, “%s“, a); /从文件 in.dat 中读取一个字符串赋给字符串 a chg (a); /调用函数 chg(a)对字符串 a 进行处理 fprintf(wf, “%sn“, a); /把处理结果写入到 out.dat 文件中 fclo

4、se(rf); fclose (wf); (分数:100.00)_三级数据库技术-523 答案解析(总分:100.00,做题时间:90 分钟)一、设计与应用题(总题数:1,分数:100.00)1.程序 test.c 的功能是:把 s 字符串中的所有字符左移一个位置,串中的第一个字符移到最后。请考生编写函数 chg(char*s)实现程序要求,最后调用函数 readwriteDAT()把结果输出到 out.dat 文件中。 例如:s 字符串中原有内容为:Mn.123xyZ,则调用该函数后,结果为:n.123xyZM。 请勿改动数据文件 in.dat 中的任何数据、主函数 main()和输出函数

5、readwriteDAT()的内容。 #include stdio.h #include string.h #define N 81 /定认宏变量 N, 其值等于 81 void readwriteDAT(); void chg(char *s) main () char a N ; printf(“Enter a string:“); gets(a); printf(“The original string is: “); puts(a); chg (a); printf (“The string after modified:“); puts (a); readwriteDAT (); /

6、从文件 in.dat 中读入字符串赋给字符串变量 a,调用函数 chg(a)对字符串按照题目的要求进行处理,并把处理结果写入到文件 out.dat 中*/ void readwriteDAT() int i; char a N; FILE *rf, *wf; rf=fopen(“in.dat“, “r“); wf=fopen(“out.dat“, “w“); for(i=0; i10; i+) fscanf (rf, “%s“, a); /从文件 in.dat 中读取一个字符串赋给字符串 a chg (a); /调用函数 chg(a)对字符串 a 进行处理 fprintf(wf, “%sn“

7、 a); /把处理结果写入到 out.dat 文件中 fclose(rf); fclose (wf); (分数:100.00)_正确答案:()解析:int i; char first, *p=s; first=*s; /把字符串 s 的第一个字符赋给 first /*把 s 字符串中的所有字符左移一个位置,串中的第一个字符移到最后*/ for(i=0; i(int) strlen(s)-1; i+) *(p+i)=*(p+i+1); /字符*(p+i+1)左移一位 pstrlen(s)-1=first; /第一个字符移动到字符串 s 的最后位置 解析 所有字符左移一个位置,串中的第一个字符移到最后。 定义循环变量 i,字符变量 first 和字符指针变量 p,并使 p 指向字符串 s。 把字符串 s 的第一个字符赋给。first 变量保存起来。 在 for 循环语句中,循环变量 i 从 0 开始,依次递增直到其值等于或大于(int)strlen(s)-1,把*(p+i+1)的值赋给*(p+i),实现把字符串 s 中的所有字符左移一个位置,循环结束后,把 first 的值赋给pstrlen(s)-1,即把字符串的首字符移动到字符串的最后位置上。

展开阅读全文
相关资源
猜你喜欢
  • DIN 30802-1-2004 Technique of transshipment in the transportation chain - Unloading of bulk freight wagons - Part 1 Interfaces for wagons unloading equipment《运输链中的转船技术 散装货物货车的卸载 第1.pdf DIN 30802-1-2004 Technique of transshipment in the transportation chain - Unloading of bulk freight wagons - Part 1 Interfaces for wagons unloading equipment《运输链中的转船技术 散装货物货车的卸载 第1.pdf
  • DIN 30802-2-2005 Technique of transshipment in the transportation chain - Unloading of bulk freight wagons - Part 2 Interfaces for side-discharge hopper wagon unloading equipment《运.pdf DIN 30802-2-2005 Technique of transshipment in the transportation chain - Unloading of bulk freight wagons - Part 2 Interfaces for side-discharge hopper wagon unloading equipment《运.pdf
  • DIN 30802-3-2005 Technique of transshipment in the transportation chain - Unloading of bulk freight wagons - Part 3 Interfaces for axial-discharge hopper wagon unloading equipment《.pdf DIN 30802-3-2005 Technique of transshipment in the transportation chain - Unloading of bulk freight wagons - Part 3 Interfaces for axial-discharge hopper wagon unloading equipment《.pdf
  • DIN 30803-2005 Technique of transshipment in the transportation chain - Defrosting antifreeze protection for hopper wagons《运输链中转运技术 自动倾卸车的除霜 防冻保护》.pdf DIN 30803-2005 Technique of transshipment in the transportation chain - Defrosting antifreeze protection for hopper wagons《运输链中转运技术 自动倾卸车的除霜 防冻保护》.pdf
  • DIN 30823-2001 Intermediate bulk containers - Rigid IBC - Metal rigid plastics and composite intermediate bulk containers Dimensions design requirements marking《中等容量容器 硬质IBC 金属、硬质、.pdf DIN 30823-2001 Intermediate bulk containers - Rigid IBC - Metal rigid plastics and composite intermediate bulk containers Dimensions design requirements marking《中等容量容器 硬质IBC 金属、硬质、.pdf
  • DIN 3089-2-1984 Steel wire ropes splices long splice《钢丝绳 绳头 长绳头》.pdf DIN 3089-2-1984 Steel wire ropes splices long splice《钢丝绳 绳头 长绳头》.pdf
  • DIN 30901-2016 Heat treatment of ferrous materials - Determination of the depth and form of appearance of the internal oxidation《黑色金属材料的热处理 内氧化深度和外观形式的测定》.pdf DIN 30901-2016 Heat treatment of ferrous materials - Determination of the depth and form of appearance of the internal oxidation《黑色金属材料的热处理 内氧化深度和外观形式的测定》.pdf
  • DIN 30902-2016 Heat treatment of ferrous materials - Light-microscopical determination of the depth and porosity of the compound layer of nitrided and nitro-carburized ferrous part.pdf DIN 30902-2016 Heat treatment of ferrous materials - Light-microscopical determination of the depth and porosity of the compound layer of nitrided and nitro-carburized ferrous part.pdf
  • DIN 3091-1988 Thimbles solid thimbles for wire ropes《索环 钢丝绳索用刚性索环》.pdf DIN 3091-1988 Thimbles solid thimbles for wire ropes《索环 钢丝绳索用刚性索环》.pdf
  • 相关搜索

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

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