| ||||||||||
| 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 | |||||||||
CB上运行没错……为啥就是说compile error……求助,谢谢#include<stdio.h>
#include<string.h>
int main()
{
int sl,sn,i,j,k,p,m,n;
scanf("%d %d",&sl,&sn);
getchar();
int z[sn];
char s[sn][sl+1],w[sl+1];
for(i=0;i<sn;i++) {
j=0;z[i]=0;
while((s[i][j]=getchar())!='\n') j++;
s[i][j]='\0';
for(m=0;m<sl;m++){
for(n=m+1;n<sl;n++) {
if(s[i][m]>s[i][n]) z[i]++;
}
}
}
for(i=0;i<sn;i++) {
k=z[i];
for (j=i+1;j<sn;j++) {
if(k>z[j]) {k=z[j];p=j;}
}
if(p!=i) {
k=z[i];z[i]=z[p];z[p]=k;
strcpy(w,s[i]);strcpy(s[i],s[p]);strcpy(s[p],w);
}
}
for(i=0;i<sn;i++) printf("%s\n",s[i]);
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator