| ||||||||||
| 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>
#include <string.h>
char str[101][51]; //修改成char str[101][101]; 就通过,51就WA,是怎么回是啊???
char t[51];//同上
int s[101];
int main()
{
int m,n,i,j,k,c,min;
scanf("%d %d",&n,&m);
for(i=0;i<m;i++)
{
scanf("%s",str[i]);
c=0;
for(j=0;j<=n;j++)
for(k=j+1;k<=n;k++)
if(str[i][j]>str[i][k]) c++;
s[i]=c;
}
for(i=1;i<m;i++)
{
for(j=i-1;j>=0;j--)
{
if(s[i]<s[j]) continue;
else break;
}
min=j+1;
if(j!=i-1)
{
strcpy(t,str[i]);c=s[i];
for(j=i-1;j>=min;j--) {strcpy(str[j+1],str[j]);s[j+1]=s[j];}
strcpy(str[min],t);s[min]=c;}
}
for(i=0;i<m;i++)
printf("%s\n",str[i]);
return 1;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator