javascript - 排序算法可视化
问题描述
我需要显示每个内部 for 循环的完成结果,但是在执行时,它直接显示最终结果。
const reframe = ()=>{
ele = document.querySelectorAll(".element");
ele.forEach((el,index) =>{
el.style.height = `${arr[index]}px`;
});
}
const selection_sort= ()=>{
for( let j = 0 ; j< n-1 ; j++){
for(let k = j+1 ; k<n ;k++){
if(arr[j]>arr[k])
{
let temp = arr[j];
arr[j] = arr[k];
arr[k] = temp;
console.log(arr);
}
reframe();
}
}
}
最终输出..我需要更改每个循环的可视化
解决方案
推荐阅读
- c++ - 有人可以解释一下复制功能的作用吗?
- c# - 循环 devexpress 控件 WinForms
- delphi - 为什么 Delphi IBX TWideMemoField 转换 UTF8 字符串中的字节顺序以及如何避免它?
- kubernetes - Kubernetes kubeflow 扩展不起作用
- python - Tcl_AsyncDelete 错误。无法终止 Tk
- python - 在点之间画一条线以使用 python 进行比较、绘图和分析
- python - QCalendarWidget - 读取选定日期的背景颜色
- opencv - 前景的图像密度
- android - 使用会话从android向服务器POST数据
- string - 当对象创建具有连接时,String 保存在哪里?