All pastes #1405642 Raw Edit

Untitled

public text v1 · immutable
#1405642 ·published 2009-04-28 02:16 UTC
rendered paste body
#!/bin/ksh
#
# CS2351 - UNIX Programming, Spring 2009
# Section 401
# Program 2
# Name: Fischer, Sean
#


# read string
#string="13 -8 87 91 12 -1 -97 34 0"
#set -A array $string
#i=0

#while (( i < 9 ))
#	do
#		echo ${array[$i]}
#		(( i += 1 ))
#	done

#string="one two three four"
#set -A array $string
#echo ${array[0]}

min=0
tmp=0

for i in $array
do
	min=$i
	for j in $array
	# iterate j to the end of $array
	do
		if ${array[$j]} < ${array[$min]}
		then
			min=$j
		fi
	done
	# swap array[i] and array[min]
	tmp=${array[$i]}
	a[$i]=${array[$min]}
	a[$min]=$tmp
done