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 |
第一道vector 1A 泪流啊#include <iostream> #include <string> #include <algorithm> #include <vector> #include <cstdlib> using namespace std; int main() { int m,n; string str[100]; int a[100]; std::vector<std::pair<int,string> > vec; int i,j,k; cin>>n>>m; for(i=0;i<m;i++) cin>>str[i]; for(i=0;i<m;i++) { a[i]=0; for(j=0;j<n;j++) for(k=j;k<n;k++) if(str[i].at(j)>str[i].at(k)) a[i]++; } //for(i=0;i<m;i++)cout<<"a["<<i<<"]="<<a[i]<<endl; for(i=0;i<m;i++) { vec.push_back(std::make_pair(a[i],str[i])); } sort(vec.begin(),vec.end()); for(i=0;i<vec.size();i++) cout<<vec[i].second<<endl; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator