Home >Backend Development >PHP Tutorial >Java, java official website_PHP tutorial

Java, java official website_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:24:104300browse

Java, java official website

Java

        <span>int</span> [] array1 = {1,3,5,7,9,10,2,15,154,10,2,188,200};<span>//</span><span>定义一个数组,内容为混乱大小</span>
        <span>int</span> index = 0;<span>//</span><span>定义一个最大值或最小值的位置</span>
        <span>int</span> keyValue = 0;<span>//</span><span>定义最大值或最小值</span>
        <span>int</span> temp = 0;<span>//</span><span>定义一个临时存储变量</span>
        <span>for</span>(<span>int</span> i=0;i<array1.length;i++){<span>//</span><span>依次循环所有数据</span>
            index = i;<span>//</span><span>将i位置赋值给index</span>
            keyValue = array1[index];<span>//</span><span>将i位置的值赋值给keyValue</span>
            <span>for</span>(<span>int</span> y=i;y<array1.length;y++){<span>//</span><span>再次循环所有变量,不过这次是长度起始长度为i,最大长度不变</span>
                <span>if</span>(array1[y] < keyValue){<span>//</span><span>如果循环到的值小于i位置的值</span>
                    index = y;<span>//</span><span>位置重新定义为当前位置</span>
                    keyValue = array1[y];<span>//</span><span>最小值为当前位置</span>
<span>                }
            }
            temp </span>= array1[i];<span>//</span><span>将i位置的值赋值给临时变量(最大值)</span>
            array1[i] = array1[index];<span>//</span><span>将i位置重新定义为index(最小)位置的</span>
            array1[index] = temp;<span>//</span><span>将最大值重新定义给index位置,实现交换过程</span>
<span>        }
        </span><span>for</span>(<span>int</span> p=0;p<array1.length;p++<span>){
            System.out.print(array1[p]</span>+" "<span>);
        }</span>
<?<span>php

</span><span>/*</span><span> 选择排序::对数组进行从小到大的排序 </span><span>*/</span>
<span>$array</span> = <span>array</span>(2, 100, 3, 50, 48, 99, 502, 30, 27, 15, 16, 300, 11, 9, 5, 4, 42<span>);
</span><span>for</span> (<span>$i</span> = 0; <span>$i</span> < <span>count</span>(<span>$array</span>); <span>$i</span>++<span>) {
    </span><span>$index</span> = <span>$i</span>; <span>//</span><span>将index设置为当前循环步长</span>
    <span>$keyValue</span> = <span>$array</span>[<span>$index</span>]; <span>//</span><span>将最小值设置为当前</span>
    <span>for</span> (<span>$y</span> = <span>$i</span>; <span>$y</span> < <span>count</span>(<span>$array</span>); <span>$y</span>++<span>) {
        </span><span>if</span>(<span>$array</span>[<span>$y</span>] < <span>$keyValue</span>){ <span>//</span><span>如果循环余下的数据,有比i更小的值</span>
            <span>$index</span> = <span>$y</span>; <span>//</span><span>记录最小值的索引位置</span>
            <span>$keyValue</span> = <span>$array</span>[<span>$index</span>];<span>//</span><span>将最小值设置为最小值索引位置的值</span>
<span>        }
    }
    </span><span>$temp</span> = <span>$array</span>[<span>$i</span>]; <span>//</span><span>将当前循环的值赋值给临时变量(最大值)</span>
    <span>$array</span>[<span>$i</span>] = <span>$array</span>[<span>$index</span>];<span>//</span><span>将最小值赋值给当前位置</span>
    <span>$array</span>[<span>$index</span>] = <span>$temp</span>;<span>//</span><span>将最小值的位置填充上最大值</span>
<span>}
 </span><span>print_r</span>(<span>$array</span><span>);
</span>?>

What is += in java?

What is JAVA?

Java is an object-oriented programming language that can write cross-platform application software. It is a Java programming language launched by Sun Microsystems in May 1995. The general name of Java platform (i.e. JavaSE, JavaEE, JavaME). Java technology has excellent versatility, efficiency, platform portability and security. It is widely used in personal PCs, data centers, game consoles, scientific supercomputers, mobile phones and the Internet. It also has the world's largest professional community of developers. .

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/827775.htmlTechArticleJava, java official website Java int [] array1 = {1,3,5,7,9,10,2 ,15,154,10,2,188,200}; // Define an array whose content is chaos size int index = 0; // Define the position of a maximum or minimum value...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn