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

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

1、三级数据库技术-529 及答案解析(总分:100.00,做题时间:90 分钟)一、设计与应用题(总题数:1,分数:100.00)1.函数 ReadDat()实现从文件 in.dat中读取一篇英文文章存入到字符串数组 xx中,请编制函数StrCharJR(),其函数的功能是:以该文章中的行为单位把字符串中的所有字符的二进制 ASCII值右移 4位,高位补 0,然后把右移后的字符 ASCII值再加上原字符的 ASCII值,得到新的值仍存入原字符串对应的位置上,之后把已处理的结果仍按行重新存入数组 xx中。最后 main()函数调用函数 WriteDat()把结果xx输出到文件 out.dat中。

2、例如: “z“对应的 ASCII值为 7AH,二进制值为 01111010,右移 4位后为 00000111,加上原来“z“的 ASCII值01111010得到 10000001结果。 原始数据文件存放的格式是:每行的宽度均小于 80个字符,含标点符号和空格,并也按字符处理。 请勿改动主函数 main()、读函数 ReadDat()和输出函数 WriteDat()的内容。 #include stdio.h #include string.h char xx50 80; int maxline=0; /*文章的总行数*/ int ReadDat (void); void WriteDat (vo

3、id); void StrCharJR(void) void main () if (ReadDat () printf(“数据文件 in.dat不能打开!n007“); return; StrCharJR (); WriteDat (); /*从文件 in.dat中读取一篇英文文章存入到字符串数组 xx中*/ int ReadDat (void) FILE *fp; int i=0; char *p; if ( (fp=fopen (“in.dat“, “r“) ) =NULL) return 1; while(fgets(xxi,80,fp) != NULL) p=strchr(xxi,

4、n“); if(p) *p=0; i+; maxline=i; fclose(fp); return 0; /*把结果 xx输出到文件 out.dat中*/ void WriteDat(void) FILE *fp; int i; fp=fopen(“out.dat“, “w“); for(i=0; imaxline; i+) printf(“%sn“, xxi); fprintf(fp, “%sn“, xxi); fclose(fp); (分数:100.00)_三级数据库技术-529 答案解析(总分:100.00,做题时间:90 分钟)一、设计与应用题(总题数:1,分数:100.00)1.

5、函数 ReadDat()实现从文件 in.dat中读取一篇英文文章存入到字符串数组 xx中,请编制函数StrCharJR(),其函数的功能是:以该文章中的行为单位把字符串中的所有字符的二进制 ASCII值右移 4位,高位补 0,然后把右移后的字符 ASCII值再加上原字符的 ASCII值,得到新的值仍存入原字符串对应的位置上,之后把已处理的结果仍按行重新存入数组 xx中。最后 main()函数调用函数 WriteDat()把结果xx输出到文件 out.dat中。 例如: “z“对应的 ASCII值为 7AH,二进制值为 01111010,右移 4位后为 00000111,加上原来“z“的 AS

6、CII值01111010得到 10000001结果。 原始数据文件存放的格式是:每行的宽度均小于 80个字符,含标点符号和空格,并也按字符处理。 请勿改动主函数 main()、读函数 ReadDat()和输出函数 WriteDat()的内容。 #include stdio.h #include string.h char xx50 80; int maxline=0; /*文章的总行数*/ int ReadDat (void); void WriteDat (void); void StrCharJR(void) void main () if (ReadDat () printf(“数据文件

7、 in.dat不能打开!n007“); return; StrCharJR (); WriteDat (); /*从文件 in.dat中读取一篇英文文章存入到字符串数组 xx中*/ int ReadDat (void) FILE *fp; int i=0; char *p; if ( (fp=fopen (“in.dat“, “r“) ) =NULL) return 1; while(fgets(xxi,80,fp) != NULL) p=strchr(xxi, “n“); if(p) *p=0; i+; maxline=i; fclose(fp); return 0; /*把结果 xx输出到

8、文件 out.dat中*/ void WriteDat(void) FILE *fp; int i; fp=fopen(“out.dat“, “w“); for(i=0; imaxline; i+) printf(“%sn“, xxi); fprintf(fp, “%sn“, xxi); fclose(fp); (分数:100.00)_正确答案:()解析:int i,j; unsigned char tmp; /定义无符号字符变量 tmp /*对文章每一行的字符串进行按照题目的要求进行处理*/ for(i=0;imaxline;i+) /*对文章第 i行的每一个字符的 ASCII码值的二进制数

9、右移 4位后,得到新的值与原字符的 ASCII码相加的和,赋给原字符*/ for(j=0; j(int) strlen(xxi); j+) tmp=(xxij4); /字符 xxij的 ASCII码的二进制数右移 4位后,所得的值赋给 tmp xxij+=tmp;/tmp的 ASCII码与 xxij的 ASCII码相加后赋给 xxij 解析 字符的 ASCII值右移 4位二进制位,高位补 0后加原字符的 ASCII值。 定义两个循环变量 i、j 和一个无符号字符变量 tmp。 在第一个 for循环语句中,循环变量 i从 0开始,依次递增直到其值等于文章最大行数 maxline。,在第二个 for循环中,从每行第 1个字符开始,依次递增直到其值等于该行字符串的最大长度,然后在循环体中指定每次循环时,将第 i行第 i个位置上的字符的 ASCII值的二进制数右移 4位,然后将所得的值再加上原字符的 ASCII码值。

展开阅读全文
相关资源
猜你喜欢
  • KS M ISO 11997-1-2011 Paints and varnishes-Determination of resistance to cyclic corrosion conditions-Part 1:Wet(salt fog) dry humidity《涂料和清漆 耐周期性腐蚀的测定 第1部分 湿(盐雾) 干燥 湿度影响试验》.pdf KS M ISO 11997-1-2011 Paints and varnishes-Determination of resistance to cyclic corrosion conditions-Part 1:Wet(salt fog) dry humidity《涂料和清漆 耐周期性腐蚀的测定 第1部分 湿(盐雾) 干燥 湿度影响试验》.pdf
  • KS M ISO 11998-2008 Paints and varnishes-Determination of wet-scrub resistance and cleanability of coatings《涂料和清漆 涂层耐湿式洗涤和可清洗性测定》.pdf KS M ISO 11998-2008 Paints and varnishes-Determination of wet-scrub resistance and cleanability of coatings《涂料和清漆 涂层耐湿式洗涤和可清洗性测定》.pdf
  • KS M ISO 12058-1-2006 Plastics Determination of viscosity using a falling-ball viscometer-Part 1:Inclined-tube method《塑料 使用落球式粘度计测定粘度 第1部分 斜管法》.pdf KS M ISO 12058-1-2006 Plastics Determination of viscosity using a falling-ball viscometer-Part 1:Inclined-tube method《塑料 使用落球式粘度计测定粘度 第1部分 斜管法》.pdf
  • KS M ISO 1209-1-2012 Rigid cellular plastics-Determination of flexural properties-Part 1:Basic bending test《硬质泡沫塑料 挠曲试验 第1部分 挠曲性的测定》.pdf KS M ISO 1209-1-2012 Rigid cellular plastics-Determination of flexural properties-Part 1:Basic bending test《硬质泡沫塑料 挠曲试验 第1部分 挠曲性的测定》.pdf
  • KS M ISO 1209-2-2012 Rigid cellular plastics-Determination of flexural properties-Part 2:Determination of flexural strength and apparent flexural modulus of elasticity《硬质泡沫塑料 挠曲试验 .pdf KS M ISO 1209-2-2012 Rigid cellular plastics-Determination of flexural properties-Part 2:Determination of flexural strength and apparent flexural modulus of elasticity《硬质泡沫塑料 挠曲试验 .pdf
  • KS M ISO 12137-2012 Paints and varnishes-Determination of mar resistance《涂料和清漆 耐损性测定》.pdf KS M ISO 12137-2012 Paints and varnishes-Determination of mar resistance《涂料和清漆 耐损性测定》.pdf
  • KS M ISO 123-2007 Rubber latex-Sampling《橡胶胶乳 取样》.pdf KS M ISO 123-2007 Rubber latex-Sampling《橡胶胶乳 取样》.pdf
  • KS M ISO 126-2009 Natural rubber latex concentrate-Determination of dry rubber content《浓缩天然橡胶胶乳 干胶含量的测定》.pdf KS M ISO 126-2009 Natural rubber latex concentrate-Determination of dry rubber content《浓缩天然橡胶胶乳 干胶含量的测定》.pdf
  • KS M ISO 1268-8-2012 Fibre-reinforced plastics-Methods of producing test plates-Part 8:Compression moulding of SMC and BMC《纤维增强塑料 试验板的制备方法 第8部分 SMC和BMC的压缩模制》.pdf KS M ISO 1268-8-2012 Fibre-reinforced plastics-Methods of producing test plates-Part 8:Compression moulding of SMC and BMC《纤维增强塑料 试验板的制备方法 第8部分 SMC和BMC的压缩模制》.pdf
  • 相关搜索

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

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