
卖家暂未授权典枢平台对该文件进行数据验证,您可以向卖家
申请验证报告
。 数据描述
目录
Content
Chapter_1
Chapter_1
第九类 字符串(单词)的倒置和删除问题
94、函数ReadDat()实现从文件IN.DAT中读取一篇英文文章存入到字符串数组xx中,请编制函数StrOL(),其函数的功能是:以行为单位对行中以空格或标点符号为分隔的所有单词进行倒排。最后把已处理的字符串(应不含标点符号)仍按行重新存入字符串数组xx中,最后调用函数writeDat()把结果xx输出到文件OUT6.DAT中。
例如:原文: You He Me
I am a student.
结果:Me He You
student a am I
/*解法:
void Str0L(void)
{
int i,k;
char *p1,*p2;
char t[80],t1[80];
for(i=0;i{p2=p1=strchr(xx[i],'\0')-'\0';
t[0]=t1[0]='\0';
k=1;
while(k)
{
while(isalpha(*p1)==0&&p1!=xx[i]) {p1--;p2=p1;}
while(isalpha(*p1)&&p1>=xx[i]) p1--;
memcpy(t1,p1+1,p2-p1);
t1[p2-p1]=0;
strcat(t,t1);
strcat(t," ");
if(p1}
strcpy(xx[i],t);
}
} */
95、函数READDAT()实现从文件IN.DAT中读取一篇英文文章存入到字符串数组XX中;请编制函数STROR(),其函数功能是:以行为单位把字符串中的所有小写字母O左边的字符串内容移到该串的右边存放,然后并把小写字母o删除,余下的字符串内容移到已处理字符串的左边存放.最后把已处理的字符串仍按行重新存入字符串数组XX中,最后调用函数WRIT
EDAT()把结果XX输出到文件OUT5.DAT中.
例如:原文:You can create an index on any field.
you have the correct record.
结果: n any field.You can create an index
rd.yu have the crrect rec
/* 解法:
void StrOR(void)
{
int i;
char *p1,*p2,t[80];
for(i=0;i{t[0]='\0';
p2=xx[i];
while(*p2)
{if(*p2=='o') p1=p2;
p2++;
}
strcat(t,p1+1);
*p1='\0';
strcat(t,xx[i]);
p1=xx[i];
p2=t;
while(*p2)
{if(*p2!='o') *p1++=*p2;
p2++;
}
*p1='\0';
}
} */
Content
Chapter_1
Chapter_1
第九类 字符串(单词)的倒置和删除问题
94、函数ReadDat()实现从文件IN.DAT中读取一篇英文文章存入到字符串数组xx中,请编制函数StrOL(),其函数的功能是:以行为单位对行中以空格或标点符号为分隔的所有单词进行倒排。最后把已处理的字符串(应不含标点符号)仍按行重新存入字符串数组xx中,最后调用函数writeDat()把结果xx输出到文件OUT6.DAT中。
例如:原文: You He Me
I am a student.
结果:Me He You
student a am I
/*解法:
void Str0L(void)
{
int i,k;
char *p1,*p2;
char t[80],t1[80];
for(i=0;i
t[0]=t1[0]='\0';
k=1;
while(k)
{
while(isalpha(*p1)==0&&p1!=xx[i]) {p1--;p2=p1;}
while(isalpha(*p1)&&p1>=xx[i]) p1--;
memcpy(t1,p1+1,p2-p1);
t1[p2-p1]=0;
strcat(t,t1);
strcat(t," ");
if(p1
strcpy(xx[i],t);
}
} */
95、函数READDAT()实现从文件IN.DAT中读取一篇英文文章存入到字符串数组XX中;请编制函数STROR(),其函数功能是:以行为单位把字符串中的所有小写字母O左边的字符串内容移到该串的右边存放,然后并把小写字母o删除,余下的字符串内容移到已处理字符串的左边存放.最后把已处理的字符串仍按行重新存入字符串数组XX中,最后调用函数WRIT
EDAT()把结果XX输出到文件OUT5.DAT中.
例如:原文:You can create an index on any field.
you have the correct record.
结果: n any field.You can create an index
rd.yu have the crrect rec
/* 解法:
void StrOR(void)
{
int i;
char *p1,*p2,t[80];
for(i=0;i
p2=xx[i];
while(*p2)
{if(*p2=='o') p1=p2;
p2++;
}
strcat(t,p1+1);
*p1='\0';
strcat(t,xx[i]);
p1=xx[i];
p2=t;
while(*p2)
{if(*p2!='o') *p1++=*p2;
p2++;
}
*p1='\0';
}
} */

字符串(单词)的倒置和删除问题
179.26KB
申请报告