主题:数组排序打印的错误
请问各位 这个排列数组元素并且打印的错误出在哪里
#include <stdio.h>
int main(void)
{
int size;
int walk;
int smallest;
int tempdate;
int current;
int i;
int* ary;
printf("how many numbers do you want\n ");
scanf("%d",&size);
ary=(int*)malloc(sizeof(int)*size);
for(i=0;i<size;i++)
{
printf("enter the %d number",(i+1));
scanf("%d",&ary[i]);
}
printf("now softing the ary elments");
for(current=0;current<size;current++)
{
smallest=current;
for(walk=current+1;walk<=size;walk++)
if(ary[walk]<ary[current])
smallest=walk;
tempdate=ary[current];
ary[current]=ary[smallest];
ary[smallest]=tempdate;
}
for(i=0;i<size;i++)
printf("%3d",ary[i]);
free(ary);
getchar();
return(0);
}
#include <stdio.h>
int main(void)
{
int size;
int walk;
int smallest;
int tempdate;
int current;
int i;
int* ary;
printf("how many numbers do you want\n ");
scanf("%d",&size);
ary=(int*)malloc(sizeof(int)*size);
for(i=0;i<size;i++)
{
printf("enter the %d number",(i+1));
scanf("%d",&ary[i]);
}
printf("now softing the ary elments");
for(current=0;current<size;current++)
{
smallest=current;
for(walk=current+1;walk<=size;walk++)
if(ary[walk]<ary[current])
smallest=walk;
tempdate=ary[current];
ary[current]=ary[smallest];
ary[smallest]=tempdate;
}
for(i=0;i<size;i++)
printf("%3d",ary[i]);
free(ary);
getchar();
return(0);
}