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 <string.h> main() { short n, m, i, j, k; char str[101][51]={0}, t[51]={0}; long num[100]={0}, temp; scanf("%d%d", &n, &m); fflush(stdin); for(i=0; i<m; i++) { scanf("%s", str[i]); for(j=0; j<n-1; j++) for(k=j+1; k<n; k++) if(str[i][j] > str[i][k]) num[i]++; } for(i=1; i<m; i++) for(j=0; j<m-i; j++) if(num[j] > num[j+1]) { temp = num[j]; num[j] = num[j+1]; num[j+1] = temp; strcpy(t, str[j]); strcpy(str[j], str[j+1]); strcpy(str[j+1], t); } for(i=0; i<m; i++) printf("%s\n", str[i]); return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator