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

WA 啊 N遍了 大牛帮忙看下啊 我是昨天申请的号 很小的小鸟

Posted by dyygd at 2007-07-30 23:01:59 on Problem 1007
#include <iostream>
using namespace std;
int partion(int r[],int i,int j)
{
   int x;
   x=r[i];
   while(i<j)
   {  
	   while(i<j && x<=r[j])j--;
       if(i<j) 
	   { r[i]=r[j]; 
	     i++; 
	   }
      while(i<j && r[i]<=x)i++;
      if(i<j) 
	  {
		  r[j]=r[i]; 
	     j--; 
	  }
   }
   r[i]=x;
   return i;
}



void qsort(int r[],int l,int h)
{
     int m;
     if(l<h) 
	 {
		 m=partion(r,l,h);
	     qsort(r,l,m-1);
	     qsort(r,m+1,h); 
	 }
}

void quiksort(int r[],int n)
{
	qsort(r,0,n-1);
}



int main()
{
	int  n,m,i,tem[100]={0};
	cin>>n>>m;
	char  s[100][50];
	for(i=0;i<m;i++)
	{
	cin>>s[i];
	}
	for(int j=0;j<m;j++)
	{
		for(int k=0;k<n-1;k++)
		{
			for(int r=k+1;r<n;r++)
			{

			if(s[j][k]>s[j][r])
			{
				tem[j]++;
				
			}
			}
		}
	}

int m1[100];
for(i=0;i<m;i++)
{
  m1[i]=tem[i];
}
quiksort(tem,m);
for(i=0;i<m;i++)
{

	for(j=0;j<m;j++)
	{
		if(tem[i]==m1[j])
		{
			cout<<s[j]<<endl;
			m1[j]=-1;
		}			
	}
}

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