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() { int len=0,m,n,middata2; char middata1; int a[100][50]; char mid[100]; int mid2[100]; cin>>n>>m; for(int i=0;i<m;i++)//输入 for(int j=0;j<n;j++) cin>>a[i][j]; for(int i1=0;i1<m;i1++)//计算权值 { len=0; for(int j=0;j<n;j++) for(int k=j+1;k<n;k++) { if(a[i1][j]>a[i1][k]) len++; } mid[i1]=len; mid2[i1]=i1; } for(int i2=0;i2<m-1;i2++)//对比mid[] for(int j=0;j<m-i2-1;j++) { if(mid[j]<mid[j+1]) { middata1=mid[j]; mid[j]=mid[j+1]; mid[j+1]=middata1; middata2=mid2[j]; mid2[j]=mid2[j+1]; mid2[j+1]=middata2; } } for(int i3=0;i3<m;i3++)//利用mid2导出数组的行 { int h; h=mid2[i3]; for(int j=0;j<n;j++) cout<<a[h][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