字符串处理过程的错误

#include<iostream>
#include<cstring>
using namespace std;
int main()
{  
 int T;
  char *p1,*p2,*p3,str[1200]={0};
 cin>>T;
 while(T--)
 {
  gets(str);
  p3=p2=p1=str;
  for(;;p1++)
  { if(*p1==' '||*p1=='\0')
   { p2=p1-1;
     while(*p2!=' '||p2==p3)
      putchar(*p2),p2--;
//      if(*p2==' ')
//       cout<<' ';
   }
  if(*p1=='\0')
   break;
  }
  cout<<endl;
 }
 return 0;
}

posted on 2015-03-18 15:04  一梦千寻  阅读(84)  评论(0编辑  收藏  举报

导航