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 |
那位高手帮帮我,我总是wrong answer#include <stdio.h> #include <string.h> #define MAX1 20 #define MAX2 100 int main() { int n,m,i,j,k,t,flag[MAX1][2]; char str[MAX1][MAX2]; memset(str,0,sizeof(str)); memset(flag,0,sizeof(flag)); scanf("%d%d",&m,&n); for(i=0;i<n;i++) flag[i][0]=i; for(i=0;i<n;i++) { getchar(); for(j=0;j<m;j++) scanf("%c",&str[i][j]); } for(i=0;i<n;i++) { for(j=0;j<m;j++) { if(str[i][j]=='T') flag[i][1]+=m-j-1; else if(str[i][j]=='A'); else { for(k=j+1;k<m;k++) if(str[i][j]>str[i][k]) flag[i][1]++; } } } for(i=0;i<n;i++) for(j=0;j<n-i-1;j++) if(flag[j][1]>flag[j+1][1]) { t=flag[j+1][1]; flag[j+1][1]=flag[j][1]; flag[j][1]=t; t=flag[j+1][0]; flag[j+1][0]=flag[j][0]; flag[j][0]=t; } for(i=0;i<n;i++) { for(j=0;j<m;j++) printf("%c",str[flag[i][0]][j]); printf("\n"); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator