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 |
WA 啊 N遍了 大牛帮忙看下啊 我是昨天申请的号 很小的小鸟#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator