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 |
如此的题目怎么会WA??#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