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 |
受不了了,这几天一个程序也没写对(高人帮忙!!)#include <iostream> using namespace std; struct nx { int nx; char xulie[55]; }a[105]; int Nixu(char *str,int len) { int i; int nxx=0; int a[4]={0}; for (i=len-1;i>=0;--i) { switch(str[i]) { case 'A': a[0]++; a[1]++; a[2]++; break; case 'C': a[1]++; a[2]++; nxx+=a[0]; break; case 'G': a[2]++; nxx+=a[1]; break; case 'T': nxx+=a[2]; break; } } return nxx; } int main () { char input[55]; int n,t,nx,end,i,j,k,flag; end=0; cin>>n>>t; cin>>input; nx=Nixu(input,n); a[0].nx=nx; strcpy(a[0].xulie,input); while (--t) { flag=0; cin>>input; nx=Nixu(input,n); for (i=0;i<end;++i) { if (nx>a[i].nx) { flag=1; break; } } if (flag) { for (j=end;j>=i;--j) { a[j+1].nx=a[j].nx; strcpy(a[j+1].xulie,a[j].xulie); } a[i].nx=nx; strcpy(a[i].xulie,input); end++; } else { a[end+1].nx=nx; strcpy( a[end+1].xulie,input ); end++; } } for (k=0;k<t;++k) printf("%s\n",a[k].xulie); system ("pause"); return 0; } //始终没有找到错误 Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator