对一个数组内的整数进行排序有如下方法,请问它们是不是也属于冒泡方法呢?
![ContractedBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![ExpandedBlockStart.gif](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
void
Sort1(
int
[] arr)
{
int n = arr.Length;
int i,j,temp;
for (i = 1 ;i < n;i ++
{
for (j = 0 ;j < i;j ++ )
{
if (a[j] > a[i])
{
temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
{
int n = arr.Length;
int i,j,temp;
for (i = 1 ;i < n;i ++
{
for (j = 0 ;j < i;j ++ )
{
if (a[j] > a[i])
{
temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
}
void Sort2( int [] arr)
{
int n = arr.Length;
int i,j,temp;
for (i = 1 ;i < n;i ++
{
for (j = i;j > 0 ;j -- )
{
if (a[j - 1 ] > a[j])
{
temp = a[j];
a[j] = a[j - 1 ];
a[j - 1 ] = temp;
}
}
}
}
void Sort2( int [] arr)
{
int n = arr.Length;
int i,j,temp;
for (i = 1 ;i < n;i ++
{
for (j = i;j > 0 ;j -- )
{
if (a[j - 1 ] > a[j])
{
temp = a[j];
a[j] = a[j - 1 ];
a[j - 1 ] = temp;
}
}
}
}