Bitwise operators :
>>> unsigned right-shift operators, the rules for unsigned right shifts are the same as those that move right, except that when they are filled, they are supplemented with zeros, regardless of whether the original is positive or negative.
Array:
ARR1=ARR2; At this point two array variables will point to the same array, that is, the array to which arr2 points, and if arr2 points to an array that changes, arr1 and arr2 are changed.
Use Arrays.sort to sort (using a quick row)
Magic square Matrix : (direct to instance)
public class Magic {/** * uses multidimensional arrays to print an n-order magic square Matrix * The sum of the data elements on each column and diagonal of each row of the matrix * n takes an odd number (because of the diagonal and the sum of the rows and columns) */public void mag (int n,int a[] [])//Pass order number and array {int i = 0, j, k;j = n/2;for (k = 1; k <= n * N; k++) {A[i][j] = K;//system.out.print ("a[" +i+ "[" +j+ "]=" +a[i][j]+ ""); if (k% n = = 0) {i = (i + 1)% n;} else {i = (i-1 + N)% N;j = (j + 1)% n;}}} public static void Main (string[] args) {int n=3;int a[][] = new Int[n][n];new Magic (). Mag (n, a);//system.out.println (); for (int i = 0; i < n; i++) {for (int j = 0; J <n; J + +) {System.out.print (a[i][j]+ "\ t");} System.out.println ();}}}
Example Results:
8 1 6
3 5 7
4 9 2
Java Small Knowledge Point learning--------array and bit arithmetic small knowledge points