0

Can you check broo it's not deserved output

public class Program { int[] frequentSort(int ar[]){ int na[]=new int[ar.length]; for(int i=0;i<ar.length;i++){ for(int j=i+1;j<ar.length;j++){ if(ar[i]<ar[j]) na[i]=ar[i]; else na[i+1]=ar[j]; } } return na; } public static void main(String[] args) { int a[]={1,3,2,4,1}; Program p=new Program(); int c[]=p.frequentSort(a); for(int k=0;k<c.length;k++){ System.out.print(c[k]); } } }

25th Jan 2019, 6:22 AM
Vikash Kumar
Vikash Kumar - avatar
2 Réponses
0
import java.util.Arrays; public class Program { int[] frequentSort(int a[]) { Arrays.sort(a); return a; } public static void main(String[] args) { int a[] = { 1, 3, 2, 4, 1 }; Program p = new Program(); int c[] = p.frequentSort(a); for (int k = 0; k < c.length; k++) { System.out.print(c[k]); } } }
29th Jan 2019, 9:27 AM
Tobias
Tobias - avatar
0
Without using any method
29th Jan 2019, 9:29 AM
Vikash Kumar
Vikash Kumar - avatar