Array merging of linear tables in detail (two methods)
Recently, CSDN has never been opened, and you cannot send a blog... In the course of learning Oracle over the past few days, we have merged sequence tables. Although it is not difficult and there are many ideas, we still hope that our own things can be used for your reference ~~ There are two methods. One of them uses the Java encapsulation method, which is very simple and crude...
Import java. util. arrays; public class SeqListTest {public static void Bubble_Sort (int A [], int N) {for (int P = N-1; P> = 0; P --) {int flag = 0; for (int I = 0; I <P; I ++) {if (A [I]> A [I + 1]) {int temp = A [I]; A [I] = A [I + 1]; A [I + 1] = temp; flag = 1 ;}} if (flag = 0) break;} for (int k = 0; k <. length; k ++) {System. out. print (A [k] + "") ;}} public static void main (String args []) {int A [] = new int [] {0, 1, 2, 5, 7}; int B [] = new int [] {4, 6, 8, 9, 10}; // method 1 int I = 0; int C [] = new int [. length + B. length]; for (; I <. length; I ++) {C [I] = A [I];} int m = I; for (; m <C. length; m ++) {C [m] = B [m-B. length];}/** int j = 0; * for (; j <B. length; j ++) * {* C [m] = B [j]; m ++; *} */Bubble_Sort (C, 10); System. out. println (); // method 2 System. arraycopy (A, 0, C, 0,. length); System. arraycopy (B, 0, C,. length, B. length); Arrays. sort (C); for (int k = 0; k <C. length; k ++) {System. out. print (C [k] + "");}}}