Java Array Min Value minsort(int[] vet1)

Here you can find the source of minsort(int[] vet1)

Description

Ordina vet1 con l'algoritmo minsort

License

Open Source License

Parameter

Parameter Description
vet1 a parameter

Declaration

public static void minsort(int[] vet1) 

Method Source Code

//package com.java2s;
/*//w w  w  . j  a  va 2 s . co m
 * Copyright (C) 2007 Alberto Duina, SPEDALI CIVILI DI BRESCIA, Brescia ITALY
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

public class Main {
    /***
     * Ordina vet1 con l'algoritmo minsort
     * 
     * @param vet1
     */
    public static void minsort(int[] vet1) {

        for (int i1 = 0; i1 < vet1.length; i1++) {
            for (int i2 = i1 + 1; i2 < vet1.length; i2++) {
                if (vet1[i2] < vet1[i1]) {
                    int aux1 = vet1[i1];
                    vet1[i1] = vet1[i2];
                    vet1[i2] = aux1;
                }
            }
        }
    }

    /***
     * Ordina vet1 con l'algoritmo minsort, e sposta gli elementi di vet2 in
     * sincronia (non saprei come spiegarmi in altro modo)
     * 
     * @param vet1
     */
    public static void minsort(int[] vet1, int[] vet2) {

        int aux1 = 0;
        for (int i1 = 0; i1 < vet1.length; i1++) {
            for (int i2 = i1 + 1; i2 < vet1.length; i2++) {
                if (vet1[i2] < vet1[i1]) {
                    aux1 = vet1[i1];
                    vet1[i1] = vet1[i2];
                    vet1[i2] = aux1;
                    aux1 = vet2[i1];
                    vet2[i1] = vet2[i2];
                    vet2[i2] = aux1;
                }
            }
        }
    }

    public static void minsort(double[] vet1, double[] vet2, double[] vet3) {

        double aux1 = 0;
        for (int i1 = 0; i1 < vet1.length; i1++) {
            for (int i2 = i1 + 1; i2 < vet1.length; i2++) {
                if (vet1[i2] < vet1[i1]) {
                    aux1 = vet1[i1];
                    vet1[i1] = vet1[i2];
                    vet1[i2] = aux1;
                    aux1 = vet2[i1];
                    vet2[i1] = vet2[i2];
                    vet2[i2] = aux1;
                    aux1 = vet3[i1];
                    vet3[i1] = vet3[i2];
                    vet3[i2] = aux1;

                }
            }
        }
    }

    public static void minsort(double[] vet1, double[] vet2) {

        double aux1 = 0;
        for (int i1 = 0; i1 < vet1.length; i1++) {
            for (int i2 = i1 + 1; i2 < vet1.length; i2++) {
                if (vet1[i2] < vet1[i1]) {
                    aux1 = vet1[i1];
                    vet1[i1] = vet1[i2];
                    vet1[i2] = aux1;
                    aux1 = vet2[i1];
                    vet2[i1] = vet2[i2];
                    vet2[i2] = aux1;
                }
            }
        }
    }

    public static void minsort(double[] vet1) {

        double aux1 = 0;
        for (int i1 = 0; i1 < vet1.length; i1++) {
            for (int i2 = i1 + 1; i2 < vet1.length; i2++) {
                if (vet1[i2] < vet1[i1]) {
                    aux1 = vet1[i1];
                    vet1[i1] = vet1[i2];
                    vet1[i2] = aux1;
                }
            }
        }
    }
}

Related

  1. minOfCol(int[][] matrixTable, int colBound)
  2. minOfSortedValues(double[] sortedValues)
  3. minOfSubRange(double[] xs, int start, int end)
  4. minOverArraySubset(double[] array, Iterable subset)
  5. minPrim(final int... numbers)
  6. minValue(double array[][])
  7. minValue(double[] from)
  8. minValue(double[] values)
  9. minValue(double[] values)