package LinkedList1;
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
int m,m1,k=0;
Scanner scan=new Scanner(System.in);
System.out.println("请输入第一个数组的元素的个数");
m=scan.nextInt();
int [] a1=new int[m];
System.out.println("请输入第一个数组的元素的个数");
m1=scan.nextInt();
int [] a2=new int[m1];
int []a3=new int [a1.length+a2.length];
System.out.println("请输入第一个数组的元素");
for(int i=0;ia1[i]=scan.nextInt();
a3[k]=a1[i];
k++;
}
System.out.println("请输入第二个数组的元素");
for(int i=0;ia2[i]=scan.nextInt();
a3[k]=a2[i];
k++;
}
System.out.println("数组的元素有");
for(int i=0;iSystem.out.print(a3[i]+" ");
System.out.println();
for(int i=0;ifor(int j=0;j int t;
if(a3[i]>a3[j]){
t=a3[i];
a3[i]=a3[j];
a3[j]=t;
}
}
System.out.println("逆序后数组的元素有");
for(int i=0;iSystem.out.print(a3[i]+" ");
System.out.println();
}
}
package com.paic.elis.tag;
import java.util.Arrays;
import com.sun.xml.internal.bind.v2.runtime.unmarshaller.XsiNilLoader.Array;
public class Test {
public static void main(String[] args) {
String[] a=new String[3];
a[0]="c";
a[1]="d";
a[2]="e";
String[] b =new String[3];
b[0]="a";
b[1]="b";
b[2]="c";
String [] c=new String[a.length+b.length];
for (int i = 0; i < a.length; i++) {
c[i]=a[i];
}
for (int i = 0; i < b.length; i++) {
c[i+b.length]=b[i];
}
for (int i = 0; i < c.length; i++) {
}
Arrays.sort(c);
for (int i = 0; i < c.length; i++) {
System.out.println(c[i]);
}
}
}
数字就把String换为int就好了。其他不变。
public class Test {
public static void main(String[] args){
int[] a={1,2,3};
int[] b={4,5,6};
int[] ab=new int[a.length+b.length];
System.arraycopy(a, 0, ab, 0, a.length);
System.arraycopy(b, 0, ab, a.length, b.length);
Arrays.sort(ab);
for(int i=0;i
ab[i]=ab[ab.length-1-i];
ab[ab.length-1-i]=temp;
}
System.out.println(Arrays.toString(ab));
}
}
数组合并有要求吗?
你这个是要怎写用api行吗