计算机三级C问题

来源:百度知道 编辑:UC知道 时间:2024/06/04 09:36:33
函数ReadDat( )的功能是实现从文件ENG001IN中读取一篇英文文章,存入到字符串数组xx中。请编制函数encryChar( ),按给定的替代关系对数组xx中所有字符进行替代,仍存入数组xx的对应的位置上,最后调用函数WriteDat( )把结果xx输出到文件ps001.dat中。
替代关系:f(p)=p*11 mod 256(p是数组xx中某一个字符的ASCII值,f(p)是计算后新字符的ASCII值),如果原字符是小写字母或计算后f(p)的值小于等于32,则该字符不变,否则将f(p)所对应的字符进行替代。
注意:部分源程序已给出,原始数据文件的存放格式是每行的宽度均小于80个字符。
请勿改动主函数main()、读函数ReadDat()和写函数WriteDat()的内容。
试题程序:
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
unsigned char xx[50][80];
int maxline=0;
int ReadDat(void);
void WriteDat(void);

void encryChar()
{

}

void main()
{
system("CLS");
if(ReadDat())
{
printf("数据文件ENG001.IN不能打开!\n\007");
return;
}
encryChar();
WriteDat();
}

int ReadDat(void)
{
FILE *fp;
int i=0;
unsigned char *p;
if((fp=fopen("ENG001.IN","r"))==NUL

你把p定义成int型数据最好。fp=xx[i][j]*11 % 256 。
这里的数据xx[i][j]是字符型,但是乘11后就有可能超出字符型数据的范围。所以定义成int型就可以了。

Resume:1983 June enlists, in 1987 graduate from Chinese People's Liberation Army's ir force the eighth flight college, successive holder air force some teacher airplane pilot, medium captain, once flew models, such as strong shot machine and 歼 shot machine...etc., the safety flies for 1350 hours, drive 评 is one class airplane pilot, now is Chinese People's Liberation Army the aerospace member big brigade x-rated aerospace member;Attend an aerospace member primary election in 1996, enter the final contest;January in 1998, outshine others from more than 800 finalists, become a Chinese head batch one of the aerospace members;Carry person's irship to shoot phase zero on the fifth in "absolute being boat", by expert team election by secret ballot, select "the 3 people's head fly a steps brigade", and is made sure the leader seat a candidate