|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 |
<?php$nums = array(10,0,20,30,50,40,80);function
stor($numbers){ $length
= count($numbers); for($i=0; $i<$length-1; $i++){ for($j=$i+1; $j<$length; $j++){ if($numbers[$j] < $numbers[$i]){ $temp=$numbers[$i]; $numbers[$i]=$numbers[$j]; $numbers[$j]=$temp; } } } return
$numbers;}$array
= stor($nums);foreach($array
as $v){ echo
$v."-";}?> |
原文:http://www.cnblogs.com/chenshuo/p/3672102.html