Array merging of linear tables in detail (two methods)

Source: Internet
Author: User

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] + "");}}}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.