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 |
问题解决了……In Reply To:求助大牛帮忙,检查了好长时间,一直看不出来自己错哪了,测试数据对,但wa…… Posted by:CangelfoxC at 2006-10-01 13:24:43 > #include <iostream> > #include <cstdlib> > using namespace std; > struct node{ > int num; > int p; > }b[101]; > int compare(const void *a,const void *b){ > node* m=(node*)a; > node* n=(node*)b; > return (m->num>n->num); > } > int main(){ > int m,n; > cin >>m>>n; > char a[101][51]; > for(int i=0;i<n;i++){ > b[i].num=0; > b[i].p=i; > for(int j=0;j<m;j++){ > cin >>a[i][j]; > } > for(int k=m-2;k>=0;k--){ > for(int l=k+1;l<m;l++){ > if(a[i][k]>a[i][l]) > b[i].num++; > } > } > } > qsort(b,n,sizeof(node),compare); > for(i=0;i<n;i++){ > for(int j=0;j<m;j++){ > cout <<a[b[i].p][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