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 |
Re:请高手帮我看看为什么sample测试是对的,而且个人觉得算法是对的.提上去却是wrong answer?In Reply To:请高手帮我看看为什么sample测试是对的,而且个人觉得算法是对的.提上去却是wrong answer? Posted by:h2x at 2005-08-14 22:19:34 > #include <stdio.h> > #include <string.h> > > int main(){ > char (*ch)[51]; > char *chr; > int n, m, i, j; > scanf("%d%d", &n, &m); > ch = new char[m][51]; > for(i=0; i<m; ++i) > scanf("%s",ch[i]); > int k[50]; > for(i=0; i<m; ++i){ > k[i] = 0; > for(j=0; j<n-1; ++j) > for(int h=j+1; h<n; ++h) > if(ch[i][j]>ch[i][h]) > ++k[i]; > } > int k1; > chr = new char[51]; > for(i=0; i<m-1; ++i) > for(j=i+1; j<m; ++j) > if(k[i]>k[j]){ > strcpy(chr, ch[i]); k1=k[i]; > strcpy(ch[i],ch[j]); k[i]=k[j]; > strcpy(ch[j],chr); k[j]=k1; > } > for(i=0; i<m; ++i) printf("%s\n", ch[i]); > delete []chr; > delete []ch; > return 0; > } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator