- import java.util.Scanner;
- public class BubbleSort {
- public static void main(String[] args) {
- Scanner myScanner=new Scanner(System.in);
- int n;
- int[] arr=new int[100];
- System.out.print("Enter the number of elements : ");
- n=myScanner.nextInt();
- System.out.print("Enter "+n+ " numbers : ");
- for (int i = 0; i <n; i++) {
- arr[i]=myScanner.nextInt();
- }
- int temp;
- for (int i = 0; i < n; i++) {
- for (int j = i+1; j < n; j++) {
- if (arr[i]>arr[j]) {
- temp=arr[i];
- arr[i]=arr[j];
- arr[j]=temp;
- }
- }
- }
- System.out.print("Sorted list are : ");
- for (int i = 0; i < n; i++) {
- System.out.print(arr[i]+"\t");
- }
- System.out.println();
- }
- }
- //Enter the number of elements : 5
- //Enter 5 numbers : 8 34 23 424241 1
- //Sorted list are : 1 8 23 34 424241
Bubble sort in JAVA programming
Click any Bellow Tabs/Tags
Alamgir-Hossain
(14)
Algorithms
(5)
Android problem
(2)
ANN
(1)
ArticleWriting
(26)
Artificial Intelligence
(1)
Assembly
(1)
Bangla Love Poem
(3)
Bangla Poem
(2)
best programming solution
(9)
Books
(2)
BUET IICT MSC Admission
-2021
(1)
C
(49)
Campus
(7)
CPP
(88)
Database
(4)
Differences
(2)
Fishing
(1)
HSC
(1)
Html
(4)
interesting programming solution
(9)
Interview
(2)
It job preparation
(7)
JAVA
(97)
JavaScript
(5)
JSON
(1)
lead generation
(1)
machine learning
(2)
ML Projects
(3)
NewsPaper
(22)
Others
(13)
Perl
(23)
Php
(4)
Poem
(4)
Presentation
(1)
ProblemSolving
(3)
Project
(21)
project proposal
(2)
Prolog
(13)
Python
(33)
research
(23)
Research Tool
(1)
Security
(3)
Social Engineering
(1)
Testimonials
(5)
Tutorial
(2)
Writings
(15)
XML
(1)
YoutubeSEO
(1)
উক্তি
(1)
কবিতা-আলগীর হোসেন
(2)
রম্য
(1)
লেখনী
(34)
No comments:
Post a Comment