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 <stdlib.h> const int N = 60; const int M = 101; int n, m; struct node { char string[N]; int num; }; struct node str[M]; void cacu (struct node &A) { int i, j; for (i = 0; i < n - 1; i ++) for (j = i + 1; j < n; j ++) { if (A.string[i] <= A.string[j]) { A.num ++;//统计正常顺序数目 } } } int cmp (const void *p, const void *q) { struct node *a, *b; a = (struct node *)p; b = (struct node *)q; return a->num < b->num; } int main () { int i, j; scanf ("%d %d", &n, &m); for (i = 0; i < m; i ++) { scanf ("%s", str[i].string); str[i].num = 0; cacu (str[i]); } qsort (str, m, sizeof (str[0]), cmp); for (i = 0; i < m; i ++) { printf ("%s\n", str[i].string); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator