冒泡排序

<!DOCTYPE html>
<html lang= "en" >

<head>
<meta charset= "UTF-8" >
<meta name= "viewport" content= "width=device-width, initial-scale=1.0" >
<meta http-equiv= "X-UA-Compatible" content= "ie=edge" >
<title>Document </title>
</head>

<body>
<script>
var a = 3 ,
b = 5 ,
c = 1 ,
d = - 1 ,
temp ;
if ( a > b ) {
temp = a ;
a = b ;
b = temp ;
}
if ( b > c ) {
temp = b ;
b = c ;
c = temp ;
}
if ( c > d ) {
temp = c ;
c = d ;
d = temp
}
if ( a > c ) {
temp = a ;
a = c ;
c = temp ;
}
console . log ( a , b , c , d )
< /script>
</body>

</html>

猜你喜欢

转载自blog.csdn.net/SFwords/article/details/80053998