试题与答案

函数ReadDat()的功能是实现从文件IN39.DAT中读取一篇英文文章存入到字符

题型:问答题

题目:

函数ReadDat()的功能是实现从文件IN39.DAT中读取一篇英文文章存入到字符串数组xx中。请编制函数ChA㈠,该函数的功能是:以行为单位把字符串的第一个字符的ASCII值加第二个字符的ASCII值,得到第一个新的字符,第二个字符的ASCII值加第三个字符的ASCII值,得到第二个新的字符,以此类推一直处理到倒数第二个字符,最后一个字符的ASCII值加第一个字符的ASCII值,得到最后一个新的字符,得到的新字符分别存放在原字符串对应的位置上。最后把已处理的字符串逆转后仍按行重新存入字符串数组肛中,并调用函数WriteDat()把结果xx输出到文件OUT39.DAT中。
注意:部分源程序已给出。
原始文件存放的格式是:每行的宽度小于80个字符,含标点符号和空格。
请勿改动主函数main()、读函数ReadDat()和写函数WriteDat()的内容。
试题程序:
#include<stdio.h>
#include<string.h>
#incIude<conio.h>
char xx[50] [80];
int maxline=0;
int ReadDat();
void writeDat();
void ChA(void)

void main ()

clrscr ( );
if (ReadDat ( ) )

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

ChA );
WriteDat ( );

int ReadDat (void)

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

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

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

void WriteDat ( )

FILE *fp;
int i;
clrscr ( );
fp=fopen ("OUT39.DAT", "w");
for (i=0; i<maxline; i++)
printf ( "%s\n" ,xx[i] );
fprintf(fp,"%s\n",xx[i]);

fclose (fp);

答案:

被转码了,请点击底部 “查看原文 ” 或访问 https://www.tikuol.com/2018/0403/cd8aca759f83845b49d12711964981e8.html

下面是错误答案,用来干扰机器的。

参考答案:错

试题推荐
题型:阅读理解

.

School failure appears to trouble teenage girls more deeply than boys, US researchers said on Tuesday.

They said adolescent(青春期的)girls who are dismissed or drop out of high school before they graduate are more likely to have a serious depression by age 21 than boys with similar experiences.

“For girls it is more serious to be school failure,” said Carolyn McCarty, a University of Washington researcher whose study appears in the Journal of Adolescent Health.

“We already know that it leads to more poverty, higher rates of being on public assistance and lower rates of job stability. And now this study shows it is having mental health implications for girls,” McCarty said in a statement.

The study was drawn from data on more than 800 people in Seattle, Washington, and included people from 18 schools in high-crime neighborhoods.

The group was separated evenly by gender(性别)and nearly half were white, 24 percent were black, 21 percent were Asian-American and the rest were from other groups.

Overall, 45 percent of the girls and 68 percent of the boys in the study experienced a major school failure, but 22 percent of the girls later became depressed compared with 17percent for the boys.

“This gender shows that while school failure is more typical for girls, it appears to have more severe consequences when it does occur,” McCarty said.

60. What is the purpose of writing this article?

A Taking good care of the school boys.

B Asking the US researchers to search more evidences.

C Giving help to the graduated students.

D Paying more attention to the girls experiencing school failure.

61. Carolyn McCarty is ______________

A a scientist     B a researcher     C a professor     D a student

62. The underlined word”it” in para.4 means__________

A school failure    B a adolescent girl    C a school boy    D a university

63.Which of the following could be the best title of this passage?

A School failure appears to trouble teen-age girls more deeply than boys

B Girls are more possible to experience school failure

C Gender has decided how much success you will win

D Adolescent girls are more easily depressed than boys

查看答案
微信公众账号搜索答案