1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
#include <bits/stdc++.h>
#define all(G) G.begin(), G.end()
using namespace std;
bool compare( string rhs, string lhs) {
int a, b;
sscanf( string(rhs.rbegin(), rhs.rend()).c_str(), "%*s%d", &a );
sscanf( string(lhs.rbegin(), lhs.rend()).c_str(), "%*s%d", &b );
return ( a > b );
}
int main() {
deque <string> words = {
"100 appears 1 times.", "1984 appears 1 times.",
"2 appears 1 times.", "a appears 8 times.",
"all appears 1 times.", "be appears 4 times.",
"come appears 1 times.", "two appears 1 times.",
"used appears 3 times.", "user appears 3 times.",
"very appears 1 times.", "when appears 1 times.",
"will appears 7 times.", "with appears 2 times.",
"word appears 3 times.", "words appears 6 times.",
"write appears 1 times.", "written appears 1 times.",
"x appears 6 times.", "y appears 2 times"
};
sort( all(words), compare );
for ( auto F: words )
cout << F << endl;
}
|