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

Why

Posted by carew at 2005-10-07 12:25:41 on Problem 1007
#include "iostream"
#include "string"
using namespace std;

int len,n;

void test(string s,int &e)
{
	int i,j;
	for(i=0;i<len;i++)
		for(j=i+1;j<len;j++)
			if(s[i]>s[j]) e++;
}

int main()
{
    int i,j;
    int *a;
    string *p;
    char *c;

    cin>>len>>n;
	a=new int[n];
	c=new char[len];
	p=new string[n];
	for(i=0;i<n;i++)
	{
		cin>>c;
		p[i]=c;
		a[i]=0;
	    test(p[i],a[i]); 
	}
    for(j=1;j<=len*(len+1)/2;j++)
	for(i=0;i<n;i++)
	if(a[i]==j) cout<<p[i]<<endl;
	return 0;
}

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