Bubble sort
public class Mathgroup {
public static void Main (string[] args) {
Int[] arr= {13,43,25,36,45};
for (int x=0;x<arr.length-1;x++) {
for (int y=0;y<arr.length-1-x;y++) {
if (Arr[y]>arr[y+1]) {
int num=arr[y];
ARR[Y]=ARR[Y+1];
Arr[y+1]=arr[y];
}
}
}
SYSTEM.OUT.PRINTLN ("Array sort result is:");
GeSHi (arr);
}
public static void GeSHi (int[] a) {
System.out.print ("[");
for (int i=0;i<a.length;i++) {
if (i==a.length-1) {
System.out.print (a[i]+ "]");
}else {
System.out.print (a[i]+ ",");
}
}
}
}
Select sort
public class Choolse {
public static void Main (string[] args) {
Int[] arr= {13,43,25,36,45};
for (int x=0;x<arr.length;x++) {
for (int y=0;y<arr.length;y++) {
if (Arr[x]>arr[y]) {
int num=arr[x];
Arr[x]=arr[y];
Arr[y]=num;
}
}
}
System.out.println (arrays.tostring (arr));
}
}
Math:
public static int abs (int a)
Gets the absolute value of the given data
public static double Ceil (double A)
Gets the smallest double integer that is larger than the given data
public static double floor (double a)
Gets the largest integer of type double, which is smaller than the given data
public static int max (int a,int b)
Get the maximum value in two numbers
public static Double pow (double a,double b)
Returns a power of B
public static double Random ()
Generate a random number between [0.0-1.0]
public static int round (float a)
Rounded
public static double sqrt (double A)
Positive square root
Random:
public int Nextint ()
Get a random number in the INT range
public int Nextint (int n)
System
Get a random number between 0 and N [n]
public static void GC ()
Garbage collector
public static void exit (int status)
Terminating a currently running Java Virtual machine
public static long Currenttimemillis ()
Gets the millisecond value of the difference between the current system time and 1970-01-01 00:00:00
Bubble sort, select Sort, Math,random,system