Maison >Java >javaDidacticiel >Explication détaillée de l'utilisation de la sélection, du tri à bulles et de la méthode de recherche binaire
[] array = { 31, 22, 15, 77, 52, 32, 18, 25, 16, 7 ( j = 0; j
import java.util.Arrays;//选择排序public class Test {public static void main(String[] args) {int[] array = { 31, 22, 15, 77, 52, 32, 18, 25, 16, 7 };// 选择 --> 第一位与后面所有的数字进行比较 System.out.println(Arrays.toString(array));for (int i = 0; i
[] array = { 3, 10, 15, 22, 33, 51, 77, 88= "输入需要插入的数据:" number = left = 0 right = array.length - 1 result =[] newArray = [array.length + 1 ( i = 0; i 0 (array[array.length - 1]
show( width, ( i = 0; i
//for循环打印菱形public class Rhombus {public void show(int height) {int half = height / 2;for (int i = 1; i 0; j--) { System.out.print(" "); }for (int j = 0; j 0; j--) { System.out.print(" "); }for (int j = 0; j
//for循环打印等腰三角形public class Isosceles {public void show(int height) {for (int i = 1; i 0; j--) { System.out.print(" "); }for (int j = 0; j
//for循环打印之间三角形public class Triangle {public void show(String str, int height) {for (int i = 0; i
Ce qui précède est le contenu détaillé de. pour plus d'informations, suivez d'autres articles connexes sur le site Web de PHP en chinois!