求救:简单的c语言编程

来源:百度知道 编辑:UC知道 时间:2024/05/13 04:25:21
问题:一篇文章xx[50][80],以行为单位把You and Me变成Me and You
请帮忙填充%%%%%%%%%%%部分,语句越简单越短越好,拜托啦!!

#include <stdio.h>
#include <string.h>
#include <conio.h>
#include <ctype.h>
char xx[50][80] ;
int maxline = 0 ;/* 文章的总行数 */
int ReadDat(void) ;
void WriteDat(void) ;
void StrOL(void)
{
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
}
main()
{
clrscr() ;
if (ReadDat ())
{
printf("数据文件 IN2.DAT不能打开!\n\007") ;
return ;
}
StrOL() ;
WriteDat() ;
}
int ReadDat(void)
{
FILE *fp ;
int i = 0 ;
char *p;
if((fp = fopen("IN2.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 StrOL(void)
{
static char temp[80];
int i;
for (i = 0; i < maxline; i++)
{
char *start, *end, *t;
int n = strlen(xx[i]);
int iwrite = 0;
start = end = &xx[i][n-1];

iwrite = 0;
for(;;)
{
while (start >= xx[i] && *start != ' ') start--;
start++;/*start指向最要分析的单词的开始的字母*/

/*复制单词start...end*/
for (t = start; t <= end; temp[iwrite++] = *t++);

if (start == xx[i])
{/*如果已经指向首字母*/
temp[iwrite] = '\0';
break;
}

start--;/*start指向空格*/
/*注意本程序在两个单词中有多个空格的时候多个空格不会处理成一个空格*/
while (start >= xx[i] && *start == ' ')
temp[iwrite++] = ' ', start--;/*start指向下一个单词的最后一个字母*/

end = start;
}

strcpy(xx[i], temp);
}
}

这不是三级考试题库的题吗?
我看过,
蛮难的...