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:tear at 2003-08-28 23:28:26 要这样 int compare( const void* a,const void *b) { return (sorted[*(int *)a]>sorted[*(int *)b])? 1: (sorted[*(int *)a]<sorted[*(int *)b])?-1:0 ; } > #include <stdio.h> > #include <stdlib.h> > char map[100][51]; > int sign[100]; > int value[100]; > int n, m; > int cmp(const void *a, const void *b) > { > return value[*(int *)a] > value[*(int *)b]; > } > int main() > { > int i, j, k; > scanf("%d %d", &m, &n); > for(i = 0 ; i < n; i++) > { > sign[i] = i; > scanf("%s", map[i]); > value[i] = 0; > for(j = 0 ; j < m - 1; j++) > { > for(k = j + 1; k < m; k++) > { > if(map[i][j] > map[i][k]) > value[i]++; > } > } > } > qsort(sign, n, sizeof(sign[0]), cmp); > for(i = 0 ; i < n ; i++) > { > printf("%s\n", map[sign[i]]); > } > > return 1; > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator