标签:
student. a am I I‘m a Freshman and I like JOBDU!
I am a student. JOBDU! like I and Freshman a I‘m
1 #include <cstdio> 2 #include <cstring> 3 4 #define MAXSIZE 50001 5 6 void reverse(char *str, int low, int high) { 7 while (low < high) { 8 char temp = str[low]; 9 str[low] = str[high]; 10 str[high] = temp; 11 low++; 12 high--; 13 } 14 } 15 16 int main() { 17 char str[MAXSIZE]; 18 while (gets(str)) { 19 int low = 0, high = 0; 20 while (str[low] != ‘\0‘) { 21 high = low; 22 while (str[high] != ‘ ‘ && str[high] != ‘\0‘) 23 high++; 24 reverse(str, low, high - 1); 25 low = high; 26 while (str[low] == ‘ ‘ && str[low] != ‘\0‘) 27 low++; 28 } 29 30 reverse(str, 0, strlen(str) - 1); 31 printf("%s\n", str); 32 } 33 }
版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:
原文地址:http://blog.csdn.net/xiaogaobai/article/details/47809363