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 |
Hi guys, could you please view my code and tell me why I was wrong?This is my code: #include<iostream> #include<cstdio> #include<string.h> using namespace std; main() { int n,m; while (scanf ("%d %d", &n, &m)!=EOF) { char DNA[m][n+1]; int count[m],l=0; for(int i=m-1; i>=0; --i) { count[i]=0; fflush(stdin); cin.getline(DNA[i],n+1); int len=strlen(DNA[i]); for(int j=len-2; j>=0; --j) for(int k=len-1; k>=j+1; --k) if(DNA[i][j]>DNA[i][k]) ++count[i]; } // for(int k=m-1; k>=0; --k) { int imin=0; int min=count[0]; //Ok for(int i=m-l-1; i>=0; --i) if(count[i]<min) { min=count[i]; imin=i; } cout<<DNA[imin]<<endl; for(int i=0; i<m-l-1; i++) if(count[i]==count[m-1-l]) { char temp[n+1]; strcpy(temp,DNA[i]); strcpy(DNA[i],DNA[m-1-l]); strcpy(DNA[m-1-l],temp); break; } count[imin]=count[m-1-l]; strcpy(DNA[imin],DNA[m-1-l]); ++l; } } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator