codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
#include <iostream> #include <map> #include <vector> #include <boost/algorithm/string.hpp> #define ci const_iterator using namespace std; int main() { typedef string s; typedef vector<s> vs; vs l; copy(istream_iterator<s>(cin), istream_iterator<s>(), back_inserter(l)); map<s, vs> r; for (vs::ci i = l.begin(), e = l.end(); i != e; ++i) { s a = boost::to_lower_copy(*i); sort(a.begin(), a.end()); r[a].push_back(*i); } for (map<s, vs>::ci i = r.begin(), e = r.end(); i != e; ++i) if (i->second.size() > 1) *copy(i->second.begin(), i->second.end(), ostream_iterator<s>(cout, " ")) = "\n"; }
Private
[
?
]
Run code
Submit