赞
踩
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; getchar(); while (n--) { string s; getline(cin, s); cout << s << endl; while (s[0] == ' ') s.erase(s.begin()); while (s[s.length() - 1] == ' ') s.erase(s.end() - 1); for (int i = 0; i<s.length(); i++) if (s[i] == ' ') { while (s[i + 1] == ' ') s.erase(s.begin() + i + 1); if (!isalnum(s[i+1])) s.erase(s.begin() + i); } for (int i = 0; i<s.length(); i++) if (s[i] >= 'A'&&s[i] <= 'Z'&&s[i] != 'I')s[i] -= 'A' - 'a'; for (int beg = 0;; beg++) { beg = s.find("can you", beg); if (beg == -1)break; if ((!beg||!isalnum(s[beg-1]))&&(beg+7==s.length()||!isalnum(s[beg+7]))) s.replace(beg,7,"A can"); } for (int beg = 0;; beg++) { beg = s.find("could you", beg); if (beg == -1)break; if ((!beg||!isalnum(s[beg-1]))&&(beg+9==s.length()||!isalnum(s[beg+9]))) s.replace(beg,9,"A could"); } for (int beg = 0;; beg++) { beg = s.find("I", beg); if (beg == -1)break; if ((!beg||!isalnum(s[beg-1]))&&(beg+1==s.length()||!isalnum(s[beg+1]))) s.replace(beg,1,"you"); } for (int beg = 0;; beg++) { beg = s.find("me", beg); if (beg == -1)break; if ((!beg||!isalnum(s[beg-1]))&&(beg+2==s.length()||!isalnum(s[beg+2]))) s.replace(beg,2,"you"); } for (int i=0;i<s.length();i++) { if (s[i] == '?')s[i] = '!'; if (s[i] == 'A')s[i] = 'I'; } cout << "AI: " << s << endl; } return 0; }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。