shell学习笔记(二)
来源:互联网 发布:淘宝卖家版注册 编辑:程序博客网 时间:2024/05/01 17:50
http://cyent.blog.51cto.com/905592/745659
http://www.cnblogs.com/skyaspnet/archive/2010/11/03/1868298.html
#Normal Quick-Sort algorithm Quick_Sort(){ #Sort Numeric-array in ASC order, using normal Quick-Sort algorithm. #C code: http://www.cnblogs.com/skyaspnet/archive/2010/11/03/1868298.html #Usage: Quick_Sort lowest_index highest_index array_name #e.g., Quick_Sort 0 9 array1 #e.g., Quick_Sort 1 3 array2 local pivot=${t_array[${1}]} local low=${1} local high=${2} [ ${1} -ge ${2} ] && return while (( low < high )); do local pivot=${t_array[${1}]} local low=${1} local high=${2} [ ${1} -ge ${2} ] && return while (( low < high )); do while (( low < high )) && [ ${pivot} -le ${t_array[${high}]} ]; do ((high--)) done if [ ${pivot} -gt ${t_array[${high}]} ]; then t_array[${low}]=${t_array[${high}]} t_array[${high}]=${pivot} ((low++)) fi while (( low < high )) && [ ${pivot} -ge ${t_array[${low}]} ]; do ((low++)) done if [ ${pivot} -lt ${t_array[${low}]}) ]; then t_array[${high}]=${t_array[${low}]} t_array[${low}]=${pivot} ((high--)) fi done #Execute the Quick_Sort function recursively Quick_Sort ${1} $[${low}-1] t_array Quick_Sort $[${low}+1] ${2} t_array unset pivot low high }main(){ read -ep "Input Numeric: " numeric t_array=(${numeric}) size=${#t_array[@]} #Output the original array for((i=0;i<size;i++)); do printf "%d " ${t_array[${i}]} done printf "\n" Quick_Sort 0 $((size-1)) t_array #Output the sorted array for((i=0;i<size;i++)); do printf "%d " ${t_array[${i}]} done printf "\n"}main
- Shell学习笔记(二)
- shell学习笔记(二)
- shell 学习 笔记(二)
- shell 学习笔记 (二)
- shell学习笔记(二)
- Shell学习笔记(二)
- shell学习笔记(二):shell 语法
- shell学习笔记(二):《Unix Shell编程》学习笔记
- shell学习笔记二
- shell学习笔记二
- UNIX Shell编程 学习笔记(二)
- learning bash shell 学习笔记(二)
- Shell学习笔记二(基本语法)
- shell学习笔记之二(变量)
- linux shell学习笔记(二)
- 【Shell】【学习笔记】Linux Shell脚本应用(二)
- Bash Shell学习笔记二
- Linux Shell学习笔记二
- linux catalina.out文件过大
- 内存分配——静态存储区 栈 堆
- java中collection接口下list arraylist vector以及 map接口下的hashmap hashtable详解
- C++ AMP: Performance Guidance for C++ AMP
- Node.js学习(2)----一些实例
- shell学习笔记(二)
- chomd操作权设置
- CPP笔记20130922
- 数据库中事务的属性
- log android调试神器
- Linux top命令输出重定向
- java异常处理机制
- Android 获取view在屏幕中的位置
- 使用 Navicat Lite 连接 Oracle 数据库