原题链接:http://ac.jobdu.com/problem.php?pid=1525
字符串简单题,注意开有结尾有空格的情况否则pe or wa
1 #include<algorithm> 2 #include<iostream> 3 #include<cstdlib> 4 #include<cstring> 5 #include<cstdio> 6 #include<string> 7 #include<vector> 8 using std::string; 9 using std::vector; 10 using std::cin; 11 const int Max_N = 100010; 12 char buf[Max_N], temp[Max_N]; 13 void reverse(char *src, int n){ 14 int i, j = n - 1; 15 for (i = 0; i < j; i++, j--){ 16 char tp = src[i]; 17 src[i] = src[j]; 18 src[j] = tp; 19 } 20 } 21 void solve(int n){ 22 int i, j; 23 vector<string> ans; 24 for (i = 0; i < n; i++){ 25 if (buf[i] != ' ' || !i){ 26 j = 0; 27 for (; buf[i] != ' ' && i < n; i++) temp[j++] = buf[i]; 28 temp[j] = '