#include
#include
int main()
{
int i=0,j=0,k=0,t=0,n=0;
char str[80]={0};
char words[20][20] ={0};
char word[20]={0};
char tmp[20]={0};
gets(str);
for (i=0;i<=strlen(str);i++)
{
if (str[i]==' ' || str[i]=='\0')
{
if (str[i]==' ' && j==0 )
{
continue;
}
word[j++] = '\0';
j=0;
strcpy(words[k++],word);
}else
{
word[j++]=str[i];
}
}
for (n=0;n{
for (i=0;i{
if (strlen(words[i])>strlen(words[i+1]))
{
strcpy(tmp,words[i]);
strcpy(words[i],words[i+1]);
strcpy(words[i+1],tmp);
}
}
}
for (n=0;n{
printf("[%d][%s]\n",n,words[n]);
}
return 0;
}
you are a ugly pig
[0][a]
[1][you]
[2][are]
[3][pig]
[4][ugly]
Press any key to continue
太感谢了!!!怎么调用文件?