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 |
Re:multimap比较好吧O.OIn Reply To:用map做的应该还满容易理解的 Posted by:foreverlin at 2008-11-13 08:54:11 #include<stdio.h> #include<iostream> #include<map> #include<string> #include<algorithm> using namespace std; int reorder(string str) { int count=0; for(int i=0;i<str.length()-1;i++) { for(int j=i+1;j<str.length();j++) { if(str[j]-str[i]<0) count++; } } return count; } int main() { int l,n; char s[100]; string str; multimap<int,string>DNA; multimap<int,string>::iterator it; while(scanf("%d%d",&l,&n)!=EOF) { while(n--) { scanf("%s",s); str=s; DNA.insert(pair<int,string>(reorder(str),str)); } it=DNA.begin(); while(it!=DNA.end()) { cout<<it->second<<endl; it++; } DNA.clear(); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator