mirror of
https://github.com/142vip/408CSFamily.git
synced 2026-04-23 10:10:56 +08:00
feat: 移除eslint相关配置,引入@antfu/eslint-config,统一约束风格
This commit is contained in:
@@ -20,7 +20,8 @@ function binaryInsertSort(arr, len) {
|
||||
if (arr[mid] <= temp) {
|
||||
// 右侧
|
||||
lowIndex = mid + 1
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// 左侧
|
||||
highIndex = mid - 1
|
||||
}
|
||||
@@ -35,10 +36,8 @@ function binaryInsertSort(arr, len) {
|
||||
return arr
|
||||
}
|
||||
|
||||
|
||||
// 测试用例
|
||||
const dealArr = [5, 2, 7, 3, 18, 8, 12, 1]
|
||||
console.log('插入排序前:', dealArr)
|
||||
const sortResult = binaryInsertSort(dealArr, 7)
|
||||
console.log('插入排序后:', sortResult)
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ function QuickSort(arr, low, high) {
|
||||
return arr
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* 寻找数组中的基准pivot,使得左侧元素全部小于等于pivot,右侧元素全部大于等于pivot
|
||||
@@ -47,7 +46,6 @@ function Partition(arr, low, high) {
|
||||
return low
|
||||
}
|
||||
|
||||
|
||||
const initArr = [2, 18, 6, 25, 19, 4, 8, 3, 7]
|
||||
console.log(`快速排序处理前:${initArr}`)
|
||||
const quickSortResult = QuickSort(initArr, 0, 8)
|
||||
|
||||
@@ -34,7 +34,6 @@ function specialStraightInsertSort(arr, len, increment, groupIndex) {
|
||||
for (let eleStartIndex = groupIndex + increment; eleStartIndex < len; eleStartIndex += increment) {
|
||||
// 此时eleStartIndex为直接插入排序的比较元素
|
||||
|
||||
|
||||
// 直接插入排序中的哨兵元素【重要】
|
||||
const temp = arr[eleStartIndex]
|
||||
let j
|
||||
@@ -49,13 +48,11 @@ function specialStraightInsertSort(arr, len, increment, groupIndex) {
|
||||
return arr
|
||||
}
|
||||
|
||||
|
||||
const dealArr = [5, 8, 2, 16, 3, 9, 1]
|
||||
console.log('插入排序前:', dealArr)
|
||||
const sortResult = shellSort(dealArr, 7)
|
||||
console.log('插入排序后:', sortResult)
|
||||
|
||||
|
||||
/**
|
||||
* 简化的希尔排序
|
||||
* - 返回已排序号的数组,从小到大
|
||||
@@ -77,7 +74,6 @@ function shellSortBetter(arr) {
|
||||
return arr
|
||||
}
|
||||
|
||||
|
||||
console.log('简化shellSortBetter希尔排序前:', dealArr)
|
||||
const sortResultBetter = shellSortBetter(dealArr)
|
||||
console.log('简化shellSortBetter希尔排序后:', sortResultBetter)
|
||||
|
||||
@@ -30,5 +30,3 @@ console.log('插入排序前:', dealArr)
|
||||
const sortResult = straightInsertSort(dealArr, 7)
|
||||
|
||||
console.log('插入排序后:', sortResult)
|
||||
|
||||
|
||||
|
||||
@@ -20,7 +20,8 @@ function binaryInsertSort(arr, len) {
|
||||
if (arr[mid] <= temp) {
|
||||
// 右侧
|
||||
lowIndex = mid + 1
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// 左侧
|
||||
highIndex = mid - 1
|
||||
}
|
||||
@@ -35,10 +36,8 @@ function binaryInsertSort(arr, len) {
|
||||
return arr
|
||||
}
|
||||
|
||||
|
||||
// 测试用例
|
||||
const dealArr = [5, 2, 7, 3, 18, 8, 12, 1]
|
||||
console.log('插入排序前:', dealArr)
|
||||
const sortResult = binaryInsertSort(dealArr, 7)
|
||||
console.log('插入排序后:', sortResult)
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ function QuickSort(arr, low, high) {
|
||||
return arr
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* 寻找数组中的基准pivot,使得左侧元素全部小于等于pivot,右侧元素全部大于等于pivot
|
||||
@@ -47,7 +46,6 @@ function Partition(arr, low, high) {
|
||||
return low
|
||||
}
|
||||
|
||||
|
||||
const initArr = [2, 18, 6, 25, 19, 4, 8, 3, 7]
|
||||
console.log(`快速排序处理前:${initArr}`)
|
||||
const quickSortResult = QuickSort(initArr, 0, 8)
|
||||
|
||||
@@ -34,7 +34,6 @@ function specialStraightInsertSort(arr, len, increment, groupIndex) {
|
||||
for (let eleStartIndex = groupIndex + increment; eleStartIndex < len; eleStartIndex += increment) {
|
||||
// 此时eleStartIndex为直接插入排序的比较元素
|
||||
|
||||
|
||||
// 直接插入排序中的哨兵元素【重要】
|
||||
const temp = arr[eleStartIndex]
|
||||
let j
|
||||
@@ -49,13 +48,11 @@ function specialStraightInsertSort(arr, len, increment, groupIndex) {
|
||||
return arr
|
||||
}
|
||||
|
||||
|
||||
const dealArr = [5, 8, 2, 16, 3, 9, 1]
|
||||
console.log('插入排序前:', dealArr)
|
||||
const sortResult = shellSort(dealArr, 7)
|
||||
console.log('插入排序后:', sortResult)
|
||||
|
||||
|
||||
/**
|
||||
* 简化的希尔排序
|
||||
* - 返回已排序号的数组,从小到大
|
||||
@@ -77,7 +74,6 @@ function shellSortBetter(arr) {
|
||||
return arr
|
||||
}
|
||||
|
||||
|
||||
console.log('简化shellSortBetter希尔排序前:', dealArr)
|
||||
const sortResultBetter = shellSortBetter(dealArr)
|
||||
console.log('简化shellSortBetter希尔排序后:', sortResultBetter)
|
||||
|
||||
@@ -30,5 +30,3 @@ console.log('插入排序前:', dealArr)
|
||||
const sortResult = straightInsertSort(dealArr, 7)
|
||||
|
||||
console.log('插入排序后:', sortResult)
|
||||
|
||||
|
||||
|
||||
@@ -20,7 +20,8 @@ function binaryInsertSort(arr, len) {
|
||||
if (arr[mid] <= temp) {
|
||||
// 右侧
|
||||
lowIndex = mid + 1
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// 左侧
|
||||
highIndex = mid - 1
|
||||
}
|
||||
@@ -35,10 +36,8 @@ function binaryInsertSort(arr, len) {
|
||||
return arr
|
||||
}
|
||||
|
||||
|
||||
// 测试用例
|
||||
const dealArr = [5, 2, 7, 3, 18, 8, 12, 1]
|
||||
console.log('插入排序前:', dealArr)
|
||||
const sortResult = binaryInsertSort(dealArr, 7)
|
||||
console.log('插入排序后:', sortResult)
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* 给定一个数组,按照从小到大或从大到小排序,打印排序前后结果对比
|
||||
* 编程语言:TypeScript
|
||||
*/
|
||||
function BubbleSort(arr:Array<number>):number[] {
|
||||
function BubbleSort(arr: Array<number>): number[] {
|
||||
// 获取数组长度
|
||||
const len = arr.length
|
||||
|
||||
@@ -33,10 +33,14 @@ function BubbleSort(arr:Array<number>):number[] {
|
||||
return arr
|
||||
}
|
||||
|
||||
interface SwitchValue {
|
||||
a: number
|
||||
b: number
|
||||
}
|
||||
/**
|
||||
* 将两个变量数值交换
|
||||
*/
|
||||
function switchValue(params:{ a: number, b: number }):{a:number, b:number} {
|
||||
function _switchValue(params: SwitchValue) {
|
||||
const { a: newB, b: newA } = params
|
||||
return { a: newA, b: newB }
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ function QuickSort(arr, low, high) {
|
||||
return arr
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* 寻找数组中的基准pivot,使得左侧元素全部小于等于pivot,右侧元素全部大于等于pivot
|
||||
@@ -47,7 +46,6 @@ function Partition(arr, low, high) {
|
||||
return low
|
||||
}
|
||||
|
||||
|
||||
const initArr = [2, 18, 6, 25, 19, 4, 8, 3, 7]
|
||||
console.log(`快速排序处理前:${initArr}`)
|
||||
const quickSortResult = QuickSort(initArr, 0, 8)
|
||||
|
||||
@@ -34,7 +34,6 @@ function specialStraightInsertSort(arr, len, increment, groupIndex) {
|
||||
for (let eleStartIndex = groupIndex + increment; eleStartIndex < len; eleStartIndex += increment) {
|
||||
// 此时eleStartIndex为直接插入排序的比较元素
|
||||
|
||||
|
||||
// 直接插入排序中的哨兵元素【重要】
|
||||
const temp = arr[eleStartIndex]
|
||||
let j
|
||||
@@ -49,13 +48,11 @@ function specialStraightInsertSort(arr, len, increment, groupIndex) {
|
||||
return arr
|
||||
}
|
||||
|
||||
|
||||
const dealArr = [5, 8, 2, 16, 3, 9, 1]
|
||||
console.log('插入排序前:', dealArr)
|
||||
const sortResult = shellSort(dealArr, 7)
|
||||
console.log('插入排序后:', sortResult)
|
||||
|
||||
|
||||
/**
|
||||
* 简化的希尔排序
|
||||
* - 返回已排序号的数组,从小到大
|
||||
@@ -77,7 +74,6 @@ function shellSortBetter(arr) {
|
||||
return arr
|
||||
}
|
||||
|
||||
|
||||
console.log('简化shellSortBetter希尔排序前:', dealArr)
|
||||
const sortResultBetter = shellSortBetter(dealArr)
|
||||
console.log('简化shellSortBetter希尔排序后:', sortResultBetter)
|
||||
|
||||
@@ -30,5 +30,3 @@ console.log('插入排序前:', dealArr)
|
||||
const sortResult = straightInsertSort(dealArr, 7)
|
||||
|
||||
console.log('插入排序后:', sortResult)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user