标签:names void bsp tar ptr ios include main end
#include<iostream> using namespace std; void RevStr(char *src) { char *start=src,*end=src,*ptr=src; while(*ptr++!=‘\0‘) { if(*ptr==‘ ‘||*ptr==‘\0‘) { end=ptr-1; while(start<end) swap(*start++,*end--); start=end=ptr+1; } } start=src,end=ptr-2; while(start<end) { swap(*start++,*end--); } } int main() { char src[]="there is a dog !"; cout <<src<<endl; RevStr(src); cout <<src<<endl; return 0; }
标签:names void bsp tar ptr ios include main end
原文地址:http://www.cnblogs.com/zoudajia/p/6270363.html