#include <stdio.h>
#include <ctype.h>
#define N 1024
int main(void)
{
char str[N+1]={' '},buf[N];
while (fgets(str+1 , N , stdin)!=NULL)
{
char *wb,*we,*ps,*pd;
for (we=str+1 ; *we ; we++)
if (!isalpha(*we))*we=' ';
for (pd=buf ; we!=str ; we=wb)
{
while (*--we==' ');
for (wb=we ; *wb!=' ' ; wb--);
for (ps=wb ; ps<=we ; *pd++=*ps++);
}
*pd='\0';
puts(buf+1);
}
return 0;
}
气死我了,居然用了四个指针……将就着看吧……我脑子抽筋了……
#include <ctype.h>
#define N 1024
int main(void)
{
char str[N+1]={' '},buf[N];
while (fgets(str+1 , N , stdin)!=NULL)
{
char *wb,*we,*ps,*pd;
for (we=str+1 ; *we ; we++)
if (!isalpha(*we))*we=' ';
for (pd=buf ; we!=str ; we=wb)
{
while (*--we==' ');
for (wb=we ; *wb!=' ' ; wb--);
for (ps=wb ; ps<=we ; *pd++=*ps++);
}
*pd='\0';
puts(buf+1);
}
return 0;
}
气死我了,居然用了四个指针……将就着看吧……我脑子抽筋了……