排序默写第三遍
2022/3/28 23:53:20
本文主要是介绍排序默写第三遍,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>排序默写第三遍</title> </head> <body> <script> function bubbleSort(arr) { for (let i = 0; i < arr.length - 1; i++) { for (let j = 0; j < arr.length - 1 - i; j++) { if (arr[j] > arr[j + 1]) { [arr[j], arr[j + 1]] = [arr[j + 1], arr[j]]; } } } return arr; } let arr = [1, 2, 22, 2, 21, 11]; function selectionSort(arr) { let minIndex; for (let i = 0; i < arr.length - 1; i++) { minIndex = i; for (let j = i + 1; j < arr.length; j++) { if (arr[minIndex] > arr[j]) { minIndex = j; } } [arr[minIndex], arr[i]] = [arr[i], arr[minIndex]]; } return arr; } function quickSort(arr) { if (arr.length <= 1) { return arr; } let left = []; let right = []; let middleIndex = Math.floor(arr.length / 2); let middleValue = arr[middleIndex]; arr.splice(middleIndex, 1); for (let i = 0; i < arr.length; i++) { if (arr[i] < middleValue) { left.push(arr[i]); } else { right.push(arr[i]); } } return quickSort(left).concat(middleValue, quickSort(right)); } function searching(arr, target) { let start = 0; let end = arr.length - 1; let middleIndex; let middleValue; while (start < end) { middleIndex = Math.floor((start + end) / 2); middleValue = arr[middleIndex]; if (middleValue === target) { return middleIndex; } else if (middleIndex > target) { end = middleIndex - 1; } else { start = middleIndex + 1; } } return -1; } let arr1 = [...Array(10).keys()].map(x => x + 1); function flat(arr) { return arr.reduce((total, cur) => { return total.concat(Array.isArray(cur) ? flat(cur) : cur); }, []); } let arr2 = [1, 2, 3, [4, 5, 6, [7, 8, 9]]]; function deepCopy(obj) { let result = Array.isArray(obj) ? [] : {}; for (let key in obj) { if (obj.hasOwnProperty(key)) { if (typeof obj[key] === 'object' && obj[key] !== null) { result[key] = deepCopy(obj[key]); } else { result[key] = obj[key]; } } } return result; } let a = { a: 1, b: '2', c: { a: 1 }, d: null, e: undefined, g: [1, 2, 3] }; function add() { let _args = [...arguments]; let _adder = function () { _args.push(...arguments); return _adder; }; _adder.toString = function () { return _args.reduce((total, cur) => total + cur); }; return _adder; } function debounce(func, delay) { let timer; return function () { let context = this; let args = arguments; clearTimeout(timer); timer = setTimeout(function () { func.apply(context, args); }, delay); }; } function throttle(func, delay) { let old = 0; return function () { let context = this; let args = arguments; let now = Date.now(); if (now - old > delay) { func.apply(context, args); } }; } function throttle1(func, delay) { let timer; return function () { let context = this; let args = arguments; if (!timer) { setTimeout(function () { func.apply(context, args); }, delay); } }; } // function ispadNumber(x) { // if (x < 0) return false; // let d = 0; // let f = x; // while (f > 0) { // d = d + f%10; // f = (f-f%10) // } // } </script> </body> </html>
基本掌握了,接下来要手写了,注意字体要工整;
最近在用 vue3+ts+ant design 打算封装一个 ant design 中关于 table 的组件,发现很困难,主要 table 中用到了插槽;
这篇关于排序默写第三遍的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-23Springboot应用的多环境打包入门
- 2024-11-23Springboot应用的生产发布入门教程
- 2024-11-23Python编程入门指南
- 2024-11-23Java创业入门:从零开始的编程之旅
- 2024-11-23Java创业入门:新手必读的Java编程与创业指南
- 2024-11-23Java对接阿里云智能语音服务入门详解
- 2024-11-23Java对接阿里云智能语音服务入门教程
- 2024-11-23JAVA对接阿里云智能语音服务入门教程
- 2024-11-23Java副业入门:初学者的简单教程
- 2024-11-23JAVA副业入门:初学者的实战指南