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:请教高手,我自己运行完全正确,可在这老是RuntimeError,WHY?In Reply To:请教高手,我自己运行完全正确,可在这老是RuntimeError,WHY? Posted by:PL_ACM at 2008-12-11 14:18:17 > #include<stdio.h> > #include<string.h> > #include<stdlib.h> > typedef struct DNAxu > { > char str[120]; > int num; > }DNAxu; > void Msort(DNAxu SR[],DNAxu TR1[],int s,int t); > int main() > { > DNAxu DNA[100]; > int len,row; > int i,j; > int a[4]={0},count; > scanf("%d%d",&len,&row); > for(j=0;j<row;j++) > scanf("%s",DNA[j].str); > for(i=0;i<row;i++) > { > memset(a,0,sizeof(a)); > count=0; > for(j=len-1;j>=0;j--) > { > switch( DNA[i].str[j] ){ > case 'A': > a[1]++; > a[2]++; > a[3]++; > break; > case 'C': > a[2]++; > a[3]++; > count += a[1]; > break; > case 'G': > a[3]++; > count += a[2]; > break; > case 'T': > count += a[3]; > } > } > DNA[i].num=count; > } > Msort(DNA,DNA,0,row-1); > for(i=0;i<row;i++) > printf("%s\n",DNA[i].str); > system("pause"); > return 0; > } > > void Merge(DNAxu SR[],DNAxu TR[],int i,int m,int n) > { > int j,k,a,b; > for(j=m+1,k=i;i<=m && j<=n;++k) > { > if(SR[i].num <= SR[j].num) > TR[k]=SR[i++]; > else TR[k]=SR[j++]; > } > if(i<=m) > { > for(a=k,b=i;a<=n&&b<=m;a++,b++) > TR[a]=SR[b]; > } > if(j<=n) > { > for(a=k,b=j;a<=n&&b<=n;a++,b++) > TR[a]=SR[b]; > } > } > > void Msort(DNAxu SR[],DNAxu TR1[],int s,int t) > { > int m; > if(s==t) > TR1[s]=SR[s]; > else > { > DNAxu TR2[51]; > m=(s+t)/2; > Msort(SR,TR2,s,m); > Msort(SR,TR2,m+1,t); > Merge(TR2,TR1,s,m,t); > } > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator