#include
void swap(int *p1, int *p2)
{
int temp;
temp=*p1;
*p1=*p2;
*p2=temp;
}
void ebullient_sort(int *start, int n, int increase)
{
int *p1, *p2;
if(increase)
{
for(p1=start; p1 for(p2=p1+1; p2 if(*p1>*p2)
swap(p1,p2);
}
else
{
for(p1=start; p1 for(p2=p1+1; p2 if(*p1<*p2)
swap(p1,p2);
}
}
void printarray(int *a,int n)
{
int i;
for(i=0; i printf("%3d",*(a+i));
printf("\n");
}
int main(void)
{
int a[10]={1,5,2,3,0,7,4,9,6,8};
ebullient_sort(a, 10, 1);
printarray(a,10);
return 0;
}
阅读(740) | 评论(0) | 转发(0) |