Bubble Sorting:
Class arraybub {
Private long [];
Private int nelems;
Public arraybub (INT num ){
A = new long [num];
Nelems = 0;
}
Public void insert (long item ){
A [nelems] = item;
Nelems ++;
}
Public long getelem (INT index ){
Return a [Index];
}
Public void setelem (INT index, long value ){
}
Public void bubsort (){
Int outer;
Int inner;
Long temp;
For (outer = nElems-1; outer> 1; outer --){
For (inner = 0; Inner <outer; Inner ++ ){
If (A [inner]> A [outer]) {
Temp = A [inner];
A [inner] = A [outer];
A [outer] = temp;
}
}
}
}
Public void showitem (){
For (INT I = 0; I <nelems; I ++ ){
System. Out. println ("A [" + I + "] =" + A [I]);
}
}
}
Public class bubblesort {
Public static void main (string [] ARGs ){
Arraybub AB = new arraybub (10 );
AB. insert (23 );
AB. insert (144 );
AB. insert (56 );
System. Out. println ("Before sorting ");
AB. showitem ();
AB. bubsort ();
System. Out. println ("sorted ");
AB. showitem ();
}
}
It is very simple, but I still write it myself. The end of the paper is shallow. To know this, you must be polite.