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

此题好像有问题,我认为我的正确,可提交确不正确,那位大牛帮我看一下

Posted by crazystone123456 at 2007-07-16 14:30:23 on Problem 1007
#include<iostream>
using namespace std;
int main()
{
 typedef char *cArrayPtr;
 typedef int *intPtr;
 int m,n,i,j,sum=0,temp;
 while(cin>>m>>n)
 {

  intPtr c;
  c=new int[n];
  char v[100];
  cArrayPtr * p =new cArrayPtr[n];
  for(i=0;i<n;i++)
  p[i]=new char[m];
  for(int i=0;i<n;i++)
  for(j=0;j<m;j++)
  cin>>p[i][j];
  for( i=0;i<n;i++)
  {
	 for(j=0;j<m;j++)
	 {
	  for(int k=j;k<m-1;k++)
	  if(p[i][j]>p[i][k+1])
	  sum++;
	 }
	 c[i]=sum;
	 sum=0;
  }
  for (i=0;i<n;i++)			
  for(j=i;j<n;j++)  
  if(c[i]>c[j]) 
	{
	  strcpy(v,p[i]),temp=c[i];
	  strcpy(p[i],p[j]),c[i]=c[j];
	  strcpy(p[j],v),c[j]=temp;
	}	  
	for(i=0;i<n;i++)
	 {  
		for(j=0;j<m;j++)
	    cout<<p[i][j];
		cout<<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