字符串单词逆转

 1 void Rotate(char *start,char *end)
 2 {
 3 if(start == NULL || end == NULL) return ;
 4 while(start<end)
 5 {
 6 char temp = *start;
 7 *start = *end;
 8 *end = temp;
 9 --end;++start;
10 }
11 }
12 
13 void RotateString(char *a,int n)
14 {
15 int i,j;
16 char *start =a;
17 char *end = a;
18 while(*start != '')
19 {
20 if(*start == ' ')
21 {
22 ++start;++end;
23 continue;
24 }
25  if(*end == ' ' || *end == '')
26 {
27 Rotate(start,--end);
28 start = ++end;
29 }
30 else
31 ++end;
32 }
33 start = a;
34 Rotate(start,end-1);
35 printf("%s
",a);
36 }
原文地址:https://www.cnblogs.com/susidian/p/10013157.html