1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
#include <iostream> #include <algorithm> #include <queue> #include <vector> #include <cstdlib> #include <cstdio> #include <string> #include <cstring> #include <ctime> #include <iomanip> #include <cmath> #include <set> using namespace std; int main(int argc, char *argv[]) { int cnt; cin >> cnt; getchar(); while (cnt--) { string str; getline(cin,str); str += ' '; string res; int startpos = 0,endpos = 0,status = 0;; for (int i = 0;i < str.size();i++) { if(str[i] == ' ' && status == 0){ res += ' '; } else if (status == 0) { startpos = i; status++; }else if(status == 1 && str[i] == ' '){ endpos = i-1; status--; for (int j = endpos;j >= startpos;j--) { res += str[j]; } res += ' '; }else{ } } res.erase(res.end()-1,res.end()); cout << res << endl; } return 0; } |
请替我问候出题人全家。。。
这个题绝对是良/心/题;为啥你会黄呢?给你个样例吧:
—-watashi-wa-saiko–desu!—-
—-ihsataw-aw-okias–!used—-
上面的-都是空格嗯。。。