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:ccnufu at 2008-08-27 10:45:18 #include<iostream> using namespace std; #define N 1000 int cmp(const void *p,const void *q) { int *p1 = (int *)p; int *q1 = (int *)q; return (*q1 - *p1); } int main ( ) { int length; int sets; char c; int measure[N]; char DNA[N][51]; cin>>length>>sets; if(length <= 0||sets <= 0||length > 50||sets > 100) { exit (-1); } for(int i=0;i<sets;i++) { cin>>DNA[i]; measure[i] = 0; for(int j=0;j<length-1;j++) { c = DNA[i][j]; for(int k=j+1;k<length;k++) { if(DNA[i][k] < c) { measure[i]++; } } } } qsort(measure,sets,sizeof(int),cmp); for(int f=0;f<sets;f++) { cout<<measure[f]<<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