poj 1007 wa了,,求解答
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int sort(char *s,int temp)
{
int num=0;
int i=0,j=0;
int k=0;
int swap=0;
char str[51];
memset(str,NULL,51);
for(k=0;k<temp;k++)
{
str[k] = s[k];
}
for(i=temp-1;i>0;i--)
{
for(j=0;j<i;j++)
{
if(str[j] > str[j+1])
{
swap = str[j];
str[j] = str[j+1];
str[j+1] = swap;
num++;
}
}
}
return num;
}
int min(int *num,int temp)
{
int i=0,j;
int re=0;
j=num[0];
for(i=0;i<temp;i++)
{
if(num[i] < j)
{
j=num[i];
re=i;
}
}
return re;
}
int main()
{
char str[51][100];
int row=0;
int col=0;
int temp1=0,temp2=0,temp3=0;
int num[100];
int sortnum[100];
int c=0;
memset(sortnum,NULL,100);
memset(str,NULL,5100);
memset(num,NULL,100);
scanf("%d %d",&col,&row);
for(temp1 = 0;temp1 < row; temp1++)
{
scanf("%s",&str[temp1]);
num[temp1] = sort(str[temp1],col);
}
for(temp1 = 0;temp1 < row;temp1++)
{
c = min(num,row);
num[c] = 5000;
printf("%s\n",str[c]);
}
return 0;
}