import java.util.*; class labtask9 { static int a[],n,i,j,t; public static void main(String[] args) { Scanner sc=new Scanner(System.in); System.out.println("Enter n"); int n=sc.nextInt(); int a[]=new int[n]; System.out.println("Enter "+n+" elements "); for(i=0;i<n;i++) { a[i]=sc.nextInt(); } for(int i=0;i<n;i++) { for(int j=i+1;j<n;j++) { if (a[i]>a[j]) { int t=a[i]; a[i]=a[j]; a[j]=t; } } } for(i=0;i<n;i++) { System.out.print(a[i]+" "); } } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter