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> int m,n; char array[100][51]; int sort[100][2]; void input(int k) { int i,j,tcount=0; for(i=0;i<n;i++) { scanf("%c",&array[k][i]); for(j=0;j<i;j++) if(array[k][j]>array[k][i]) tcount++; } array[k][i]='\0'; sort[k][0]=tcount; sort[k][1]=0; } int find() { int i,ti=0,min=999999; for(i=0;i<m;i++) { if((sort[i][1]==0)&&(sort[i][0]<min)) { min=sort[i][0]; ti=i; } } sort[ti][1]=1; return ti; } void run() { int i,ti; scanf("%d%d",&n,&m); getchar(); for(i=0;i<m;i++) { input(i); getchar(); } for(i=0;i<m;i++) { ti=find(); puts(array[ti]); } } int main() { run(); return 1; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator