为什么vc++6.0输出的结果不对哩?
# include <stdio.h># include <malloc.h>
void f(int *p, int len)
{
int i, j, t;
for (i=0; i<len-1; i++)
{
for (j=0; j<len-1-i; j++)
{
if (p[j] > p[j+1])
{
t = p[j];
p[j] = p[j+1];
p[j+1] = t;
}
}
}
}
int main(void)
{
int * q, len, i;
q = (int *)malloc(sizeof(int)*len);
printf("input len:\n");
scanf("%d", &len);
printf("input len number:\n");
for (i=0; i<len; i++)
scanf("%d", &q[i]);
f(q, len);
for (i=0; i<6; i++)
printf("%d ", q[i]);
printf("\n");
return 0;
}