package com.vikash.core;
public class BubbleTest1 {
public static void main(String args[]) {
int bubbles[] = { 0,5,4,3,78,6,76};
System.out.println("Beffore Sorting:");
for(int i:bubbles)
{
System.out.print(" "+i+" ");
}
System.out.println();
int t = 0;
while(t!=bubbles.length){
for (int j = 0; j < bubbles.length - 1; j++) {
if (bubbles[j] > bubbles[j + 1]) {
t = bubbles[j];
bubbles[j] = bubbles[j + 1];
bubbles[j + 1] = t;
}
}
t+=1;
}
System.out.println("After Sorting");
for (int i : bubbles)
System.out.print(" " + i + " ");
}
}
public class BubbleTest1 {
public static void main(String args[]) {
int bubbles[] = { 0,5,4,3,78,6,76};
System.out.println("Beffore Sorting:");
for(int i:bubbles)
{
System.out.print(" "+i+" ");
}
System.out.println();
int t = 0;
while(t!=bubbles.length){
for (int j = 0; j < bubbles.length - 1; j++) {
if (bubbles[j] > bubbles[j + 1]) {
t = bubbles[j];
bubbles[j] = bubbles[j + 1];
bubbles[j + 1] = t;
}
}
t+=1;
}
System.out.println("After Sorting");
for (int i : bubbles)
System.out.print(" " + i + " ");
}
}
No comments:
Post a Comment