Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 64dfd19

Browse files
Add files via upload
1 parent e60587e commit 64dfd19

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

‎Misc Programmes/Bubble_sort.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
class Bubble_sort{
2+
public static void main(String args[])
3+
{
4+
int n=Integer.parseInt(args[0]);
5+
int i;
6+
int a[]=new int[n];
7+
for (i=0;i<n;i++){
8+
a[i]=Integer.parseInt(args[i+1]);
9+
}
10+
int j,temp;
11+
for(i=0;i<n;i++)
12+
{
13+
for(j=0;j<n-i-1;j++)
14+
{
15+
if(a[j]>a[j+1])
16+
{
17+
temp=a[j];
18+
a[j]=a[j+1];
19+
a[j+1]=temp;
20+
}
21+
}
22+
}
23+
System.out.println("Numbers in ascending order:");
24+
for(i=0;i<n;i++)
25+
{
26+
System.out.println(a[i]);
27+
}
28+
}
29+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /