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 |
晒代码 终于AC了 一直都是数组小了#include<stdio.h> #include<stdlib.h> #include<string.h> #define MAX 101 #define CASES 50 int compare(const void * a,const void * b) { return (*(int *)a-*(int *)b); } void main() { int compare(const void * a,const void * b); char string[MAX][CASES]={0}; int num[MAX]={0}; int cases,len; int i,j; int con,a[4]; scanf("%d%d",&len,&cases); for(i=0;i<cases;i++) { scanf("%s",string[i]); for(j=strlen(string[i])-1,con=a[0]=a[1]=a[2]=a[3]=0;j>=0;j--) switch(string[i][j]) { case 'A': a[1]++; a[2]++; a[3]++; break; case 'C': a[2]++; a[3]++; con=con+a[1]; break; case 'G': a[3]++; con=con+a[2]; break; case 'T': con=con+a[3]; break; } num[i]=con*1000+i; } qsort(num,cases,sizeof(num[0]),compare); for(i=0;i<cases;i++) printf("%s\n",string[num[i]%1000]); } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator