mirror of
https://github.com/huihut/interview.git
synced 2025-12-18 13:04:38 +03:00
InsertSort 第一层循环结束条件修改
https://github.com/huihut/interview/issues/12#issuecomment-493734887
This commit is contained in:
@@ -16,7 +16,7 @@
|
|||||||
void InsertSort(vector<int>& v)
|
void InsertSort(vector<int>& v)
|
||||||
{
|
{
|
||||||
int len = v.size();
|
int len = v.size();
|
||||||
for (int i = 1; i < len - 1; ++i) {
|
for (int i = 1; i < len; ++i) {
|
||||||
int temp = v[i];
|
int temp = v[i];
|
||||||
for(int j = i - 1; j >= 0; --j)
|
for(int j = i - 1; j >= 0; --j)
|
||||||
{
|
{
|
||||||
@@ -30,4 +30,3 @@ void InsertSort(vector<int>& v)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user