[] array = { 31, 22, 15, 77, 52, 32, 18, 25, 16, 7 ( j = 0; j < array.length; j++ ( i = 0; i < array.length - 1 - j; i++ (array[i] < array[i + 1 temp == array[i + 1+ 1] =
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.length; i++) {for (int j = i + 1; j < array.length; j++) {if (array[i] < array[j]) {// 如果 array[0]比array[1]大,交换位置// 第三方变量tempint temp = array[i]; array[i] = array[j]; array[j] = temp; } } } System.out.println(Arrays.toString(array)); } }
[] array = { 3, 10, 15, 22, 33, 51, 77, 88= "输入需要插入的数据:" number = left = 0 right = array.length - 1 result =[] newArray = [array.length + 1 ( i = 0; i < newArray.length; i++ (i <= (i ==== array[i - 1= ( recursion([] array, left, right, (array[0] > 0 (array[array.length - 1] < center = (left + right) / 2 (left == right - 1 (array[center] >
show( width, ( i = 0; i < width; i++ ( j = 0; j < height; j++ (i == 0 || j == 0 || i == width - 1 || j == height - 1"*"" "
//for循环打印菱形public class Rhombus {public void show(int height) {int half = height / 2;for (int i = 1; i <= half; i++) {// 先打空格for (int j = half - i + 1; j > 0; j--) { System.out.print(" "); }for (int j = 0; j < 2 * i - 1; j++) { System.out.print("*"); } System.out.println(); }for (int i = 0; i < 2 * half + 1; i++) { System.out.print("*"); } System.out.println();for (int i = 1; i <= half; i++) {// 先打空格for (int j = i; j > 0; j--) { System.out.print(" "); }for (int j = 0; j < 2 * (half - i) + 1; j++) { System.out.print("*"); } System.out.println(); } } }
//for循环打印等腰三角形public class Isosceles {public void show(int height) {for (int i = 1; i <= height; i++) {// 先打空格for (int j = height - i; j > 0; j--) { System.out.print(" "); }for (int j = 0; j < 2 * i - 1; j++) { System.out.print("*"); } System.out.println(); } } }
//for循环打印之间三角形public class Triangle {public void show(String str, int height) {for (int i = 0; i < height; i++) {for (int j = 0; j < i + 1; j++) { System.out.print(str); } System.out.println(); } } }
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!