Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions sort.java
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
//JAVA PROGRAM FOR SORTING
import java.util.*;
class sort
{
public static void main(String args[])
{
Scanner d= new Scanner (System .in);
Scanner d= new Scanner (System .in);
int n,i,j,t;
n=d.nextInt();
n=d.nextInt();
int a[]=new int[n];
for(i=0;i<n;i++)
for(i=0;i<n;i++) //LOOPING CONSTRUCT FOR TAKING INPUT IN ARRAY
a[i]=d.nextInt();
for(i=0;i<n-1;i++)
{
for(j=i+1;j<n;j++)
{
if(a[i]>a[j])
{
t=a[i];
t=a[i]; //SORTING LOGIC
a[i]=a[j];
a[j]=t;
}
}
}
for(i=0;i<n;i++)
System.out.print(a[i]+" ");
System.out.print(a[i]+" "); //PRINTING OUT THE SORTED ARRAY
}
}