标签:
1 #include<iostream> 2 #include<string> 3 #include<vector> 4 #include<algorithm> 5 using namespace std; 6 bool isbrother(string str1, string str2) 7 { 8 if (str1.size() == str2.size()) 9 { 10 for (int i = 0; i<str1.size(); i++) 11 { 12 int n; 13 n = str2.find(str1[i]); 14 if (n == -1) 15 { 16 return false; 17 } 18 else 19 { 20 str2[n] = ‘0‘; 21 } 22 23 24 } 25 return true; 26 } 27 return false; 28 } 29 int main() 30 { 31 int n; 32 while (cin >> n) 33 { 34 vector<string> strings; 35 while (n) 36 { 37 string stemp; 38 cin >> stemp; 39 strings.push_back(stemp); 40 n--; 41 } 42 string f_string; 43 cin >> f_string; 44 int m; 45 cin >> m; 46 cin.clear(); 47 vector<string>b_strings; 48 for (int i = 0; i<strings.size(); i++) 49 { 50 if (strings[i] == f_string) 51 { 52 continue; 53 } 54 else 55 { 56 if (isbrother(f_string, strings[i])) 57 { 58 b_strings.push_back(strings[i]); 59 } 60 } 61 } 62 sort(b_strings.begin(), b_strings.end()); 63 cout << b_strings.size() << endl;
if(m<=b_strings.size())
cout<<b_strings[m-1]<<endl; 64 65 66 } 67 }
标签:
原文地址:http://www.cnblogs.com/ranranblog/p/5660556.html