Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
C++#include <iostream> #include <stdlib.h> #include <map> #include <string> using namespace std; int inversions(const char* s); int main(void) { int col, row = 0; string line; multimap<int,string>tableDNA; cin >> col >> row; while (row--> 0){ cin >> line; pair<int, string> p(inversions(line.c_str()), line); tableDNA.insert(p); } for (multimap<int, string>::iterator it = tableDNA.begin(); it != tableDNA.end(); it++){ cout << it->second << endl; } system("pause"); return 0; } int inversions(const char* s){ int number = 0; for (int i = 0; i < strlen(s); i++){ if (s[i] == 'A') continue; for (int j = i; j < strlen(s); j++){ if (s[i]>s[j]) number++; } } return number; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator