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 |
Re:AC codeIn Reply To:AC code Posted by:Kindevil at 2012-07-16 00:38:32 > #include<iostream> > using namespace std; > > class DNA > { > public: > int num; > char str[51]; > }; > > int reverseorder(char* m,int n) > { > int i,answer=0; > int A=0,C=0,G=0; > for(i=n-1;i>=0;i--) > { > switch(m[i]) > { > case 'A': > A++; > break; > case 'C': > C++; > answer+=A; > break; > case 'G': > G++; > answer+=A+C; > break; > case 'T': > answer+=A+C+G; > break; > } > } > return answer; > } > > int cmp(const void* a,const void* b) > { > DNA* x=(DNA*)a; > DNA* y=(DNA*)b; > return x->num-y->num; > } > > int main() > { > int i,n,m; > cin>>n>>m; > DNA* asd=new DNA[m]; > for(i=0;i<m;i++) > { > cin>>asd[i].str; > asd[i].num=reverseorder(asd[i].str,n); > } > qsort(asd,m,sizeof(DNA),cmp); > for(i=0;i<m;i++) cout<<asd[i].str<<endl; > } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator