标签:
#include<iostream> #include<string> #include<map> using namespace std; int inversionCompute(string str){ int inversionSum=0; char *cp=(char*)str.data(); for(int i=0;i<str.length()-1;i++){ for(int j=i;j<str.length()-1;j++){ if(cp[i]>cp[j+1]){ inversionSum++; } } } return inversionSum; } int main(int argc, char *argv[]){ int rowSize, lineNum; cin>>rowSize>>lineNum; string dnaSequence; multimap<int,string> intMap; for(int i=0;i<lineNum;i++){ cin>>dnaSequence; intMap.insert(make_pair(inversionCompute(dnaSequence),dnaSequence)); } for(multimap<int, string>::iterator iter=intMap.begin();iter!=intMap.end();++iter){ cout<<iter->second<<endl; } return 0; }
版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:
原文地址:http://blog.csdn.net/eddy_liu/article/details/46840727