(转载)
进入vi的命令
进入vi的命令
Vi filename 打开或新建文件,并将光标置于第一行首
Vi +n filename 打开文件,并将光标置于第n行首
Vi + filename 打开文件并将光标置于最后一行首
Vi +/pattern filename 打开文件,并将光标置于一个与pattern匹配的串处
Vi filename .. Filename 打开多个文件,依次进行编辑
//compare the consecutive numbers, larger one sinks to the bottom
void bubbleSort(int *a)
{
// int temp;
for(int j = 0; j < arraysize; j++)
{
for( int i = 0; i < arraysize - j - 1;i++ )
{
if( a[i] > a[i+1] )
{swap(a[i], a[i+1]);}
}
}
}
void heapSort(int *a)
{
for(int i = arraySize; i > 1; --i)
{
for(int k = 0; k < i; ++k)
{
// compare each element with its parent
// if the child is begger than its parent
// then swap them
// keep doing this until reaching the root
while((a[k] > a[k/2]) && (k > 0))
{
swap(a[k], a[k/2]);
k = k/2;
}
}
// After the for loop, the largest is put at a[0]
// then put the largest to the end of the array
// and find the largest of the rest in the same way
swap(a[0], a[i-1]);
}
}
void insertionSort(int *a, int n)
{
for (int j = 1; j < n; ++j)
{
int key = a[j];
// Insert A[j] into the sorted sequence A[0, 1,...,j-1]
int i = j-1;
while ((i >= 0) && (key < a[i]))
{
a[i+1] = a[i];
--i;
}
a[i+1] = key;
}
}