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 |
[求教]在VC6.0可以通过,但一提交就Wrong Answer.#include <stdio.h> #include <stdlib.h> int main() { int m,n,i,j,k,l; int *count,*flag; char *p[100]; char temp; scanf("%d%d",&n,&m); count = (int *)malloc(m*sizeof(int)); flag = (int *)malloc(m*sizeof(int)); for(i=0; i<m; i++) p[i] = (char *)malloc(n*sizeof(char)); for(i=0; i<m; i++) { count[i] = 0; flag[i] = 1; } for(i=0; i<m; i++) scanf("%s",p[i]); for(i=0; i<m; i++) for(j=0; j<n-1; j++) { temp = p[i][j]; for(k=j+1; k<n; k++) { if(temp>p[i][k]) count[i]++; } } for(i=0,k=-1,l=m; i<m && l>0; i++,l--) { if( k!=i-1 ) i--; k = i; for(j=i+1; j<m; j++) if(count[j] < count[k] && flag[j]) k = j; printf("%s\n",p[k]); flag[k] = 0; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator