count(искомый индекс) остается равным 0 по неведомой причине, как так то?
Если что, ++ в returne я уже убрал, это было просто так
package com.javarush.task.task12.task1233;
/*
Изоморфы наступают
*/
public class Solution {
public static void main(String[] args) throws Exception {
int[] data = new int[]{1, 2, 3, 5, -2, -8, 0, 77, 5, 5};
Pair<Integer, Integer> result = getMinimumAndIndex(data);
System.out.println("The minimum is " + result.x);
System.out.println("The index of the minimum element is " + result.y);
}
public static Pair<Integer, Integer> getMinimumAndIndex(int[] array) {
if (array == null || array.length == 0) {
return new Pair<Integer, Integer>(null, null);
}
int [] arr2 = array;
for(int i = 0; i< arr2.length;i++){
for(int j =0;j<arr2.length-1;j++){
int tmp;
if(arr2[j]>arr2[j+1]){
tmp = arr2[j+1];
arr2[j+1] = arr2[j];
arr2[j] = tmp;
}
}
}
int count = 0;
for(int i =0; i< array.length; i++){
if(arr2[0] == array[i]){
count = i;
}
}
return new Pair<Integer, Integer>(arr2[0], count++);
}
public static class Pair<X, Y> {
public X x;
public Y y;
public Pair(X x, Y y) {
this.x = x;
this.y = y;
}
}
}