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

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

1、三级数据库技术机试-131 及答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.函数 RData()实现从文件 IN.dat 中读取一篇英文文章,存入字符串数组 str 中,请编写函数encryptChar(),其功能是:按给定的替代关系对数组 str 中的所有字符进行替代后,仍存入数组 str 的对应位置上。最后调用函数 WData(),把结果 str 输出到 OUT.dat 文件中。替代关系:f(p)=p*11 mod 256 (p 是数组中某一个字符的 ASCII 值,f(p)是计算后新字符的 ASCII 值),如果原字符是大写字母或计算

2、后 f(p)值小于等于 32,则该字符不变,否则将 f(p)所对应的字符进行替代。原始数据文件存放的格式是:每行的宽度均小于 80 个字符。注意:部分程序已经给出。请勿改动主函数 main()、读数据函数 RData()和输出数据函数 WData()的内容。#include stdio.h#include string.h#include conio.h#include ctype.hunsigned char str50 80;int maxline = 0; /* 文章的总行数 */int RData (void);void WData (void);void encryptChar()v

3、oid main ()if (RData()printf(“数据文件 IN. dst 不能打开! /n/007“);return;encryptChar ();WData ();int RData (void)FILE *fp;int i = 0;unsigned char *p;if (fp = fopen(“IN. dat“, “r“) = NULL)return 1;while (fgets(stri, 80, fp) != NULL)p = strchr(stri, /n);if (p)*p =0;i+;maxline = i;fclose (fp);return 0;void WDa

4、ta(void)FILE *fp;int i;fp = fopen(“OUT. dat“, “w“);for (i=0; imaxline; i+)printf (“%s/n“, stri);fprintf(fp, “%s/n“, stri);fclose (fp);(分数:100.00)_三级数据库技术机试-131 答案解析(总分:100.00,做题时间:90 分钟)一、上机题(总题数:1,分数:100.00)1.函数 RData()实现从文件 IN.dat 中读取一篇英文文章,存入字符串数组 str 中,请编写函数encryptChar(),其功能是:按给定的替代关系对数组 str 中的所

5、有字符进行替代后,仍存入数组 str 的对应位置上。最后调用函数 WData(),把结果 str 输出到 OUT.dat 文件中。替代关系:f(p)=p*11 mod 256 (p 是数组中某一个字符的 ASCII 值,f(p)是计算后新字符的 ASCII 值),如果原字符是大写字母或计算后 f(p)值小于等于 32,则该字符不变,否则将 f(p)所对应的字符进行替代。原始数据文件存放的格式是:每行的宽度均小于 80 个字符。注意:部分程序已经给出。请勿改动主函数 main()、读数据函数 RData()和输出数据函数 WData()的内容。#include stdio.h#include s

6、tring.h#include conio.h#include ctype.hunsigned char str50 80;int maxline = 0; /* 文章的总行数 */int RData (void);void WData (void);void encryptChar()void main ()if (RData()printf(“数据文件 IN. dst 不能打开! /n/007“);return;encryptChar ();WData ();int RData (void)FILE *fp;int i = 0;unsigned char *p;if (fp = fopen

7、IN. dat“, “r“) = NULL)return 1;while (fgets(stri, 80, fp) != NULL)p = strchr(stri, /n);if (p)*p =0;i+;maxline = i;fclose (fp);return 0;void WData(void)FILE *fp;int i;fp = fopen(“OUT. dat“, “w“);for (i=0; imaxline; i+)printf (“%s/n“, stri);fprintf(fp, “%s/n“, stri);fclose (fp);(分数:100.00)_正确答案:(void encryptChar() int i;char *pf;for (i=0; imaxline; i+) pf = stri;while (*pf != 0) if (*pf=A continue;*pf = *pf * 11 % 256;pf +;)解析:解题思路 在 for 循环语句中对字符串数组 str 中的每个字符用逻辑表达式(*pf=A& *pf=Z)*pf*11%256=32 进行逻辑判断,如果其值为 1,则该字符不变,否则按照给定的替代关系 f(p)=p*11 mod 256 求出其要替代的字符的 ASCII 值,然后对该字符进行替代。

展开阅读全文
相关资源
猜你喜欢
  • EN 60947-5-1-2017 en Low-voltage switchgear and controlgear - Part 5-1 Control circuit devices and switching elements - Electromechanical control circuit devices.pdf EN 60947-5-1-2017 en Low-voltage switchgear and controlgear - Part 5-1 Control circuit devices and switching elements - Electromechanical control circuit devices.pdf
  • EN 60947-5-2-2007 en Low-voltage switchgear and controlgear - Part 5-2 Control circuit devices and switching elements - Proximity switches (Incorporates Amendment A1 2012)《低压开关设备和控.pdf EN 60947-5-2-2007 en Low-voltage switchgear and controlgear - Part 5-2 Control circuit devices and switching elements - Proximity switches (Incorporates Amendment A1 2012)《低压开关设备和控.pdf
  • EN 60947-5-3-2013 en Low-voltage switchgear and controlgear - Part 5-3 Control circuit devices and switching elements - Requirements for proximity devices with defined behaviour un.pdf EN 60947-5-3-2013 en Low-voltage switchgear and controlgear - Part 5-3 Control circuit devices and switching elements - Requirements for proximity devices with defined behaviour un.pdf
  • EN 60947-5-4-2003 en Low-voltage switchgear and controlgear Part 5-4 Control circuit devices and switching elements - Method of assessing the performance of low-energy contacts - S.pdf EN 60947-5-4-2003 en Low-voltage switchgear and controlgear Part 5-4 Control circuit devices and switching elements - Method of assessing the performance of low-energy contacts - S.pdf
  • EN 60947-5-5-1998 en Low-voltage switchgear and controlgear Part 5-5 Control circuit devices and switching elements C Electrical emergency stop device with mechanical latching func.pdf EN 60947-5-5-1998 en Low-voltage switchgear and controlgear Part 5-5 Control circuit devices and switching elements C Electrical emergency stop device with mechanical latching func.pdf
  • EN 60947-5-6-2000 en Low-Voltage Switchgear and Controlgear Part 5-6 Control Circuit Devices and Switching Elements DC Interface for Proximity Sensors and Switching Amplifiers (NAM.pdf EN 60947-5-6-2000 en Low-Voltage Switchgear and Controlgear Part 5-6 Control Circuit Devices and Switching Elements DC Interface for Proximity Sensors and Switching Amplifiers (NAM.pdf
  • EN 60947-5-7-2003 en Low-voltage switchgear and controlgear Part 5-7 Control circuit devices and switching elements Requirements for proximity devices with analogue output《低压开关设备和控.pdf EN 60947-5-7-2003 en Low-voltage switchgear and controlgear Part 5-7 Control circuit devices and switching elements Requirements for proximity devices with analogue output《低压开关设备和控.pdf
  • EN 60947-5-8-2006 en Low-voltage switchgear and controlgear Part 5-8 Control circuit devices and switching elements - Three-position enabling switches《低压开关设备和控制设备 第5-8部分 控制电路器件和开关元.pdf EN 60947-5-8-2006 en Low-voltage switchgear and controlgear Part 5-8 Control circuit devices and switching elements - Three-position enabling switches《低压开关设备和控制设备 第5-8部分 控制电路器件和开关元.pdf
  • EN 60947-5-9-2007 en Low-voltage switchgear and controlgear - Part 5-9 Control circuit devices and switching elements - Flow rate switches《低压开关设备和控制设备 第5-9部分 控制电路器件和开关元件 流量开关》.pdf EN 60947-5-9-2007 en Low-voltage switchgear and controlgear - Part 5-9 Control circuit devices and switching elements - Flow rate switches《低压开关设备和控制设备 第5-9部分 控制电路器件和开关元件 流量开关》.pdf
  • 相关搜索

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

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