反转字符串

void reverse(char *group,int i,int j)

{

    char c;

    while(i<j){

        c=group[i];

        group[i]=group[j];

        group[j]=c;

        ++i;--j;

    }

}

void reverse_list_word(char * group,int length)

{

    reverse(group,0,length-1);

    int first=-1,second=-1,i=0;

    while(i<length){

        

        while(i<length && group[i]==' ') ++i;

        first=i;

        while(i<length && group[i]!=' ') ++i;

        second=i-1;

        

        if(first!=-1 && first!=length)

        {

            reverse(group,first,second);

            first =-1;second=-1;

        }

         

    }

    

}

原文地址:https://www.cnblogs.com/sofard/p/10450901.html