桑海

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

 

 1 #include<iostream>
 2 #include<string>
 3 #include<sstream>
 4 using namespace std;
 5 
 6 void great(string& word)
 7 {
 8     for(int i = 0; i != word.size(); ++i)
 9         if(word[i] >= 'a' && word[i] <= 'z')
10         {
11             word[i] = word[i] - 'a' + 'A';
12         }
13 }
14 inline bool rule(string& word)
15 {
16     great(word);
17     if(word.size() < 3 || word == "AND" || word == "FOR" || word == "THE")
18         return false;
19                return true;
20 }
21 int main()
22 {
23     int n;
24     cin >> n;
25     bool flag = true;
26     string word, str, res;
27     stringstream ss;
28     cin.ignore();
29     cout << endl;
30     for(int i = 0; i < n; ++i)
31     {
32         getline(cin, str);
33         ss << str;
34         while(ss >> word)
35         {
36             if(rule(word))
37                 res += word[0];
38             word = "";
39         }
40         cout << res;
41         if(i < n-1)
42         cout << endl;
43         ss.clear();
44         res = "";
45     }
46     return 0;
47 }
48 
49 /*
50 5
51 Association for Computer Machinery
52 Institute of Electrical Engineers
53 SUN YAT SEN UNIVERSITY
54 THE LORD OF The Rings
55 netease
56 */
缩写

 

posted on 2013-07-03 21:03  桑海  阅读(225)  评论(0编辑  收藏  举报