| ||||||||||
| 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:一直WA,大牛们帮我看一下~~~多谢In Reply To:一直WA,大牛们帮我看一下~~~多谢 Posted by:yushuo718 at 2010-07-08 16:15:00 > #include <stdio.h>
> #include <stdlib.h>
>
> int main()
> {
> int n; // the length of the strings(0 < n <= 50)
> int m; // the number of the strings(0 < m <= 100)
> int i,j,k;
> char dna[110][60];
> char *aDna[60];
> int aInversion[60]={0};
> int inversion[60]={0};
> scanf("%d %d",&n,&m);
> for(i=0;i<m;i++)
> {
> scanf("%s",dna[i]);
> for(j=0;j<n;j++)
> for(k=j+1;k<n;k++)
> {
> if(dna[i][j]>dna[i][k])
> inversion[i]+=1;
> }
> }
> for(i=0;i<n;i++)
> {
> aDna[i] = dna[i];
> }
> for(i=0;i<n;i++)
> aInversion[i] = inversion[i];
> int temp = 0;
> char *tempC;
> for(i=0;i<n-1;i++)
> for(j=0;j<n-1;j++)
> {
> if(aInversion[j]>aInversion[j+1])
> {
> temp = aInversion[j];
> aInversion[j] = aInversion[j+1];
> aInversion[j+1] = temp;
> tempC = aDna[j];
> aDna[j] = aDna[j+1];
> aDna[j+1] = tempC;
> }
> }
> for(i=0;i<n;i++)
> {
> printf("%s",aDna[i]);
> printf("\n");
> }
> system("pause");
> }
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator