Poj1007

 1 #include <iostream>
 2 #include <string>
 3 #include <map>
 4 
 5 using namespace std;
 6 int Fun(const string& str,int iLen)
 7 {
 8     int count = 0;
 9     for (int i = 0; i < iLen-1;++i)
10     {
11         char tmp = str[i];
12         for (int j = i + 1; j < iLen;++j)
13         {
14             if (str[j] < tmp)
15             {
16                 ++count;
17             }
18         }
19     }
20     return count;
21 }
22 int main()
23 {
24     int iLen = 0;
25     int iNum = 0;
26     cin >> iLen >> iNum;
27     
28     multimap<int, string> mapval;
29     for (int i = 0; i < iNum;++i)
30     {
31         string str;
32         cin >> str;
33         mapval.insert(make_pair(Fun(str,iLen), str));
34     }
35     for (multimap<int, string>::const_iterator iter = mapval.begin();
36         iter != mapval.end();
37         ++iter)
38     {
39         cout << iter->second << endl;
40     }
41     return 0;
42 }

 

posted @ 2014-03-28 15:43  蛮大人  阅读(164)  评论(0编辑  收藏  举报