【计算机类职业资格】三级数据库技术-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码值。

展开阅读全文
相关资源
猜你喜欢
  • DIN EN 16851-2017 Cranes - Light crane systems German version EN 16851 2017《起重机 轻型起重机机构 德文版本EN 16851-2017》.pdf DIN EN 16851-2017 Cranes - Light crane systems German version EN 16851 2017《起重机 轻型起重机机构 德文版本EN 16851-2017》.pdf
  • DIN EN 16852-2017 Foodstuffs - Determination of ethyl carbamate in stone fruit spirits fruit marc spirits and other spirit drinks - GC-MS method German version EN 16852 2017《食品 核果酒.pdf DIN EN 16852-2017 Foodstuffs - Determination of ethyl carbamate in stone fruit spirits fruit marc spirits and other spirit drinks - GC-MS method German version EN 16852 2017《食品 核果酒.pdf
  • DIN EN 16853-2017 Conservation of cultural heritage - Conservation process - Decision making planning and implementation German version EN 16853 2017《文化遗产的保存 保存过程 决策 计划和实施 德文版本EN 1.pdf DIN EN 16853-2017 Conservation of cultural heritage - Conservation process - Decision making planning and implementation German version EN 16853 2017《文化遗产的保存 保存过程 决策 计划和实施 德文版本EN 1.pdf
  • DIN EN 16855-1-2017 Walk-in cold rooms - Definition thermal insulation performance and test methods - Part 1 Prefabricated cold room kits German version EN 16855-1 2017《步入式冷藏间 定义 隔.pdf DIN EN 16855-1-2017 Walk-in cold rooms - Definition thermal insulation performance and test methods - Part 1 Prefabricated cold room kits German version EN 16855-1 2017《步入式冷藏间 定义 隔.pdf
  • DIN EN 16857-2017 Foodstuffs - Determination of benzene in soft drinks other beverages and vegetable-based infant foods by headspace gas chromatography mass spectrometry (HS-GC-MS).pdf DIN EN 16857-2017 Foodstuffs - Determination of benzene in soft drinks other beverages and vegetable-based infant foods by headspace gas chromatography mass spectrometry (HS-GC-MS).pdf
  • DIN EN 16859-2017 Water Quality - Guidance standard on monitoring freshwater pearl mussel (Margaritifera margaritifera) populations and their environment German version EN 16859 20.pdf DIN EN 16859-2017 Water Quality - Guidance standard on monitoring freshwater pearl mussel (Margaritifera margaritifera) populations and their environment German version EN 16859 20.pdf
  • DIN EN 16865-2016 Inland navigation vessels - Connections and assembled hoses for the transfer of potable water German version EN 16865 2016《内河航行用船舶 饮用水输送连接和组装软管 德文版本EN 16865-2016》.pdf DIN EN 16865-2016 Inland navigation vessels - Connections and assembled hoses for the transfer of potable water German version EN 16865 2016《内河航行用船舶 饮用水输送连接和组装软管 德文版本EN 16865-2016》.pdf
  • DIN EN 16870-2017 Water quality - Guidance standard on determining the degree of modification of lake hydromorphology German version EN 16870 2017《水质 测定湖泊水文地貌变异程度的指引标准 德文版本EN 16870.pdf DIN EN 16870-2017 Water quality - Guidance standard on determining the degree of modification of lake hydromorphology German version EN 16870 2017《水质 测定湖泊水文地貌变异程度的指引标准 德文版本EN 16870.pdf
  • DIN EN 16872-2017 Services of Medical Doctors with additional qualification in Homeopathy (MDQH) - Requirements for health care provision by Medical Doctors with additional qualifi.pdf DIN EN 16872-2017 Services of Medical Doctors with additional qualification in Homeopathy (MDQH) - Requirements for health care provision by Medical Doctors with additional qualifi.pdf
  • 相关搜索

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

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