首页 >后端开发 >php教程 >PHP之10个整数,从小到大排序,输出排序结果

PHP之10个整数,从小到大排序,输出排序结果

WBOY
WBOY原创
2016-07-28 08:26:173206浏览

10个整数,从小到大排序,输出排序结果

<code><span>$aray</span> = <span>array</span>(<span>5</span>,<span>4</span>,<span>3</span>,<span>2</span>,<span>6</span>,<span>7</span>,<span>9</span>,<span>8</span>,<span>1</span>,<span>10</span>);
 <span>for</span>(<span>$i</span>=<span>0</span>;<span>$i</span><count>$aray);<span>$i</span>++){
      <span>for</span>(<span>$j</span>=<span>$i</span>+<span>1</span>;<span>$j</span><count>$aray);<span>$j</span>++){
          <span>$a</span>=<span>$aray</span>[<span>$i</span>];
          <span>$b</span>=<span>$aray</span>[<span>$j</span>];
          <span>if</span>(<span>$a</span>><span>$b</span>){
            <span>$aray</span>[<span>$i</span>]=<span>$b</span>;
            <span>$aray</span>[<span>$j</span>]=<span>$a</span>;
          }

      }
 }
 <span>//输出排序好的</span><span>for</span>(<span>$k</span>=<span>0</span>;<span>$k</span><count>$aray);<span>$k</span>++){
    <span>echo</span><span>$aray</span>[<span>$k</span>].<span>','</span>;

  }
</count></count></count></code>
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

以上就介绍了 PHP之10个整数,从小到大排序,输出排序结果,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn