MCPcopy Create free account
hub / github.com/DuGuQiuBai/Java / ArrayDemo

Class ArrayDemo

day13/code/day13_Array_Arrays/src/cn/itcast_01/ArrayDemo.java:6–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4 * ����
5 */
6public class ArrayDemo {
7 public static void main(String[] args) {
8 // ��������
9 int[] arr = { 24, 69, 80, 57, 13 };
10
11 /*
12 * // ��һ�αȽ� // ��1��Ϊ�˷�ֹԽ�� for (int x = 0; x < arr.length - 1 - 0; x++) {
13 * if (arr[x] > arr[x + 1]) { int temp = arr[x]; arr[x] = arr[x + 1];
14 * arr[x + 1] = temp; } } // �������� System.out.println("��һ�������");
15 * printArray(arr);
16 *
17 * // �ڶ��αȽ� // ��1��Ϊ�˷�ֹԽ�� for (int x = 0; x < arr.length - 1 - 1; x++) {
18 * if (arr[x] > arr[x + 1]) { int temp = arr[x]; arr[x] = arr[x + 1];
19 * arr[x + 1] = temp; } } // �������� System.out.println("�ڶ��������");
20 * printArray(arr);
21 *
22 * // �����αȽ� // ��1��Ϊ�˷�ֹԽ�� for (int x = 0; x < arr.length - 1 - 2; x++) {
23 * if (arr[x] > arr[x + 1]) { int temp = arr[x]; arr[x] = arr[x + 1];
24 * arr[x + 1] = temp; } } // �������� System.out.println("�����������");
25 * printArray(arr);
26 *
27 * // ���ĴαȽ� // ��1��Ϊ�˷�ֹԽ�� for (int x = 0; x < arr.length - 1 - 3; x++) {
28 * if (arr[x] > arr[x + 1]) { int temp = arr[x]; arr[x] = arr[x + 1];
29 * arr[x + 1] = temp; } } // �������� System.out.println("���Ĵ������");
30 * printArray(arr);
31 */
32
33 // for (int y = 0; y < arr.length - 1; y++) {
34 // // ? 0,1,2,3
35 // for (int x = 0; x < arr.length - 1 - y; x++) {
36 // if (arr[x] > arr[x + 1]) {
37 // int temp = arr[x];
38 // arr[x] = arr[x + 1];
39 // arr[x + 1] = temp;
40 // }
41 // }
42 // }
43
44 // ����
45 bubbleSort(arr);
46 // ��������
47 printArray(arr);
48 }
49
50 // ��������
51 public static void printArray(int[] arr) {
52 System.out.print("[");
53 for (int x = 0; x < arr.length; x++) {
54 if (x == arr.length - 1) {
55 System.out.print(arr[x]);
56 } else {
57 System.out.print(arr[x] + ", ");
58 }
59 }
60 System.out.println("]");
61 }
62
63 // ����

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected