Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  bbb
Language: JAVA
Code:
public class MaxSort{
     private static int maxn = 5;
     private static double[] a = new double[maxn];
     public static void mSort(double[] a, int n){
          double temp,m;
          int k;
          for(int i=n-1; i>=0; i--){
               m=a[0];
               k=0;
               for(int j= 0; j<=i; j++){
                    if(a[j] > m)
                         { m=a[j];
                              k=j;}

               }
          temp=a[i];
          a[i]=a[k];
          a[k]= temp;
          }


     }
     public static void write(double[] a){
          int n=a.length;
          for(int i=0; i<n; i++){
               System.out.println(a[i] + " ");
               System.out.println();
          }
     }

     public static void main(String[] args){
          double[] varg= {12,4,7,22,6};
          write(varg);
          System.out.println("Sortimi sipas MaxSort");
          mSort(varg,5);
          write(varg);
     }
}
Comments: