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 |
这倒是是怎么回事呢?#include <stdio.h> #include "string.h" char map[101][51]; int sign[101]; int value[101]; int n, m; void main() { int i, j, k; int temp; int tempsig; int tempsigvalue; int l; scanf("%d %d", &n, &m); printf("\n"); for(i = 0 ; i < m; i++) { sign[i] = i; scanf("%c", map[i]); } for(i=0;i<m;i++) { value[i] = 0; for(j = 0 ; j < n - 1; j++) { for(k = j + 1; k < n; k++) { if(map[i][j] > map[i][k]) value[i]++; } } } for(i=0;i<n-1;i++) { tempsig=i; tempsigvalue=sign[i]; temp=value[i]; for(j=i;j<n;j++) { if(value[j]>temp) { temp=value[j]; tempsig=j; tempsigvalue=sign[j]; } } sign[tempsig]=sign[i]; value[tempsig]=value[i]; sign[i]=tempsigvalue; value[i]=temp; } for(i = m-1 ; i >=0 ; i--) { printf("%s\n", map[sign[i]]); } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator