字符串排序问题(帮找错!谢谢)
# include <stdio.h>/*
2018年5月2日
对5个字符串排序
*/
int cmpd (char * x, char * y)
{
int t;
do
{
t = * x - * y;
x++;
y++;
}while (* x == * y);
if (t > 0)
return 1;
else
return 0;
}
int main (void)
{
char * a[] = {"aab","aba","boy","xigua","yang"};
int m, n;
char * p;
for (m = 0; m < 4; m++)
{
for (n = 0; n < 4 - m; n++)
{
if (cmpd (a[n], a[n + 1]))
{
p = a[n];
a[n] = a[n + 1];
a[n + 1] = p;
}
}
}
for (p = a[0]; p <= a[4]; p++)
printf ("%s\n", * p);
return 0;
}