问题 问答题

函数ReadDat()实现从IN.DAT文件中读取一篇英文文章并存入字符串数组xx中。请编写函数StrCharJR(),其函数的功能是:以行为单位把字符串中所有字符的ASCII值右移4位,然后把右移后的字符ASCII值再加上原字符的ASCII值,得到新的字符仍存入原字符串对应的位置上。最后把已处理的字符串仍按行重新存入字符串数组xx中,最后调用函数WriteDat(),把结果xx输出到OUT.DAT文件中。
原始数据文件存放的格式是:每行的宽度均小于80个字符(含标点符号和空格)。
注意:部分程序已经给出。
请勿改动主函数main()、读数据函数ReadDat()和输出数据函数WriteDat()的内容。
#include<stdio.h>
#include<string.h>
#include<conio.h>
char xx[50][80];
int maxline=0; /*文章的总行数*/
int ReadDat(void);
void WriteDat(void);
void StrCharJR(void)


void main()

if(ReadDat())

printf("数据文件IN.DAT不能打开!\n\007");
return;

StrCharJR();
WriteDat();

int ReadDat(void)

FILE *fp;
int i=0;
char *p;
if((fp=fopen("IN.DAT","r"))==NULL)
return 1;
while(fgets(xx[i],80,fp)!=NULL)

p=strchr(xx[i],’\n’);
if(p)
*p=0;
i++;

maxline=i;
fclose(fp);
return 0;

void WriteDat(void)

FILE *fp;
int i;
fp=fopen("OUT.DAT","W");
for(i=0; i<maxline;i++)

printf("%s\n",xx[i]);
fprintf(fp,"%s\n",xx[i]);

fclose(fp);

答案

参考答案:

void StreharJR(void)

int i,j,strA;

/*循环以遍历文章的每一行*/

for(i=0;i<maxline;i++)

strl=strlerl(xx[i]);

for(j=0;j<strl;j++) /*循环以遍历当前行的每一个字符*/

xx[i][j]+=xx[i][j]>>D; /*将每个字符按题目的要求进行替换*/

}

}

单项选择题
单项选择题

Until recently, most population growth has occurred in relatively dense urban environments. In (91) words, even if we were witnessing rapid population growth, that would not mean that the (92) were filling in with people. (93) , the urban areas would tend to become more crowded. Historically, we find that people have moved to (94) the jobs were. Jobs were usually in ports or locations with many natural (95) . After transportation became relatively cheap, other geographical locations became (96) of economic activity. One factor that determines where people will move to, even when transportation becomes cheap, is (97) . And individuals working in cities (98) higher incomes than those working in (99) areas. Hence, population has tended until the 1970s to (100) in our major urban centers. Recently population has (101) out of the Northeast to the South and to the West for the more pleasant climates. If people did not (102) from living in large cities, there would likely be a much more even population distribution (103) our entire land area. Probably, if this (104) the case, there would be less concern over population (105) Indeed, one need only (106) a cross-country drive or plane trip to realize how (107) populated these United States really are. This is not to say that we should or should not do something about (108) growth. The shortage of people in certain areas merely demonstrates that overpopulation in the United States is really only a problem in (109) urban environments. And this problem may be slowly correcting (110) .

A.where

B.there

C.what

D.how