Алгоритм принимает массив целых чисел (отсортированный или несортированный) и выводит количество элементов в одном массиве с индексом выше текущей позиции и, которые больше, чем текущие значения позиций индекса.
Например
вручную отсортированный массив восходящих целых чисел:
public static void main(String[] args){
// stores an array of integers
int [] myArray = {0,1,2,3};
// assuming the length of array is n
int n = myArray.length;
// counter variables
int i,c;
// starting from array index 0 to the length of the array
for(i=0;i<(n);i++){
c = 1;
while(((i+c)<n) && (myArray[i]<myArray[i+c])){
c++;
}
System.out.println("index value..."+i+", myArray value..."+myArray[i]+", number of items in array with index greater than current with values greater than current..."+(c-1));
}
}
даст выходной сигнал
index value...0, myArray value...0, number of items in array with index greater than current with values greater than current...3
index value...1, myArray value...1, number of items in array with index greater than current with values greater than current...2
index value...2, myArray value...2, number of items in array with index greater than current with values greater than current...1
index value...3, myArray value...3, number of items in array with index greater than current with values greater than current...0
для ручного отсортированного массива нисходящих целых чисел:
int [] myArray = {10,9,8};
выход:
index value...0, myArray value...10, number of items in array with index greater than current with values greater than current...0
index value...1, myArray value...9, number of items in array with index greater than current with values greater than current...0
index value...2, myArray value...8, number of items in array with index greater than current with values greater than current...0
для массива целых чисел все равно:
int [] myArray = {1,1,1};
выход будет
index value...0, myArray value...1, number of items in array with index greater than current with values greater than current...0
index value...1, myArray value...1, number of items in array with index greater than current with values greater than current...0
index value...2, myArray value...1, number of items in array with index greater than current with values greater than current...0
@bananamana что сказал, почему бы вам не попробовать выяснить это самостоятельно? Например. попробуйте запустить его? –
Заботьтесь о том, что делает функция вывода 3-аргумента()? –
@MK Вы не можете запустить алгоритм, если вы его не реализуете первыми. Это просто псевдокод. – marcog