You are viewing a single comment's thread. Return to all comments →
import java.util.Scanner; class Solution{ public static void main(String [] agrs){ Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int temp=0; int arr[] = new int[10000]; for(int i=0;i<a;i++) arr[i] = sc.nextInt(); for(int i=0;i<a;i++){ for(int j=i+1;j<a;j++){ if(arr[i]>arr[j]){ temp = arr[i]; arr[i] = arr[j]; arr[j] = temp; } } } for(int i=0;i<a;i++) System.out.print(arr[i]+" "); } }
Seems like cookies are disabled on this browser, please enable them to open this website
Correctness and the Loop Invariant
You are viewing a single comment's thread. Return to all comments →