| ||||||||||
| 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 | |||||||||
此题好像有问题,我认为我的正确,可提交确不正确,那位大牛帮我看一下#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator