反转字符串2

输入:

you are xue

输出:

xue are you
void reverse1(char *ch, int left, int right)
{
    int i = left;
    int j = right;
    while(i int main()
{
   char ch[50];
   while(cin.getline(ch, 50))
   {
       int left = 0;
       int right = 0;
       for(int i = 0; i <= strlen(ch); i++)
       {
           if(ch[i] == ' ' || i == strlen(ch))
           {
               reverse1(ch, left, right);
               left = i + 1;
           }
           else
           {
               right = i;
           }
       }
       reverse1(ch, 0, strlen(ch) - 1);
       cout<

你可能感兴趣的:(C++)