Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

第一道vector 1A 泪流啊

Posted by qqgyp at 2011-05-25 16:28:26 on Problem 1007
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator