<div class="codetitle"> <span><a style="CURSOR: pointer" data="5379" class="copybut" id="copybut5379" onclick="doCopy('code5379')"><u>复代码</u></a></span> 代码如下:</div> <div class="codebody" id="code5379"> <br><script type="text/javascript"> <br>var R1=[5,2,10,4,90,88,65,62]; <br>var R2=[5,2,10,4,90,88,65,62]; <br>function BubbleSort1(){ <br>var n=R1.length; <br>for(var i=0;i<n-1;i ){ <BR>var flag=false; <BR>for(var j=0;j<n-i;j ){ <BR>var temp; <BR>if(R1[j]<R1[j 1]){ <BR>temp=R1[j 1]; <BR>R1[j 1]=R1[j]; <BR>R1[j]=온도; <BR>} <BR>플래그=true; <BR>} <BR>if(!flag) return; <BR>} <BR>} <BR>BubbleSort1(); <BR>document.write(R1.join(",") "<br/>"); <br>function BubbleSort2() <br>{ <br>var n=R2.length; <br>for(var i=0;i<n-1;i ) <BR>{ <BR>var flag=false; <BR>for(var j=0;j<n-i;j ) <BR>{ <BR>var temp; <BR>if(R2[j]>R2[j 1]) <br>{ <br>temp=R2[j]; <br>R2[j]=R2[j 1]; <br>R2[j 1]=온도; <br>} <br>플래그=true; <br>} <br>if(!flag) return; <br>} <br>} <br><br>BubbleSort2(); <br>document.write(R2.join(",")) <br><br></script> <br> </div>