Computer Science, asked by souravmandal90530, 6 months ago

write a program input 10 number in a list and arrange them in descending order under bubble sort method. ​

Answers

Answered by manuprajapati519
2

Answer:

import java.util.Scanner;

class BubbleSortExample {

public static void main(String []args) {

int num, i, j, temp;

Scanner input = new Scanner(System.in);

System.out.println("Enter the number of integers to sort:");

num = input.nextInt();

int array[] = new int[num];

System.out.println("Enter " + num + " integers: ");

for (i = 0; i < num; i++)

array[i] = input.nextInt();

for (i = 0; i < ( num - 1 ); i++) {

for (j = 0; j < num - i - 1; j++) {

if (array[j] > array[j+1])

{

temp = array[j];

array[j] = array[j+1];

array[j+1] = temp;

}

}

}

System.out.println("Sorted list of integers:");

for (i = 0; i < num; i++)

System.out.println(array[i]);

}

}

Explanation:

Hello I have changed the program little bit so now you can input any number of integers you want.

Please I have worked hard on it then I made this program so please mark this as brainliest answer.

:)

Similar questions