- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbubble_sort.java
More file actions
Latest commit
28 lines (28 loc) · 678 Bytes
/
Copy pathbubble_sort.java
File metadata and controls
28 lines (28 loc) · 678 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
importjava.util.Scanner;
publicclassbubble_sortextendsqwertyuiop
{
publicstaticvoidmain(Stringargs[])
{
clear();
Scannersc=newScanner(System.in);
System.out.println("Enter 10 numbers: ");
inta[]=newint[10];
for(inti=0;i<10;i++)
a[i]=sc.nextInt();
intt=0;
for(inti=0;i<10;i++)
{
for(intj=i-1;j>=0;j--)
{
if(a[j]>a[j+1])
{
t=a[j];
a[j]=a[j+1];
a[j+1]=t;
}
}
}
for(inti=0;i<10;i++)
System.out.println(a[i]);
}
}