array algorithm :1), copy algorithm: for example: (int[] a={1,2,3,4,5,};
int[] b=new int[a.length];//b length is determined by the length of a;
For (int i=0;i<a.length;i++) {//write a.length or write B.length Can. The same length;
a[i]=b[i]; Copy one to b;
}
For (int i=0;i<a.length;i++) {output b: (System.out.println (b[i]+ ""));
}//output b[i] value:
2), Find algorithm (search); for example: scnner in=new Scanner (system.in);
int[] array={1,2,3,4,5,};
System.out.println ("please Enter the number you want to insert:");
int Index=in.nextint ();
Arrray[a.length-1]=index;//a.length-1: is the maximum subscript for array arrays;
For (int i=a.length-1;; i>0;i--) {
If (array[i]<array[i-1]) {
int T=array[i];//int T: with intermediate variables;
array[i]=array[i-1];
array[i-1]=t;
}else{
Break
}
}
For (int I=0;i<array.length;i++) {
System.out.println (array[i]+ "");//output array[i];
}
3), Bubble sort: for example:
For (int J=0;j<a.length-1;j++) {
If (a[j]>a[j+1]) {
int t=a[j];
a[i]=a[j+1];
a[j+1]=t;
}
}
Array algorithm: