| ||||||||||
| 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 | |||||||||
Why wrong answer???There is my source code.
#include<stdio.h>
#include<stdlib.h>
char DNA[110][55];
struct node{
int ind, inversion;
};
int compare( const void *a, const void *b )
{
node *pa = (node *)a;
node *pb = (node *)b;
return (pa->inversion * 1000 + pa->ind) - (pb->inversion * 1000 + pb->ind);
}
node temp[55];
int main(void)
{
int i, j, k, n, m;
scanf("%d %d", &n, &m);
for( i = 0 ; i < m ; i++ )
scanf("%s", DNA[i]);
for( i = 0 ; i < m ; i++ ){
temp[i].ind = i;
for( j = 0 ; j < n - 1; j++ ){
for( k = j + 1 ; k < n ; k++ ){
if( DNA[i][j] > DNA[i][k] ) temp[i].inversion++;
}
}
}
qsort( temp, m, sizeof(node), compare );
for( i = 0 ; i < m ; i++ )
printf("%s\n", DNA[temp[i].ind]);
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator