C++ sorting and keeping track of indexes

后端 未结 15 2014
甜味超标
甜味超标 2020-11-22 10:01

Using C++, and hopefully the standard library, I want to sort a sequence of samples in ascending order, but I also want to remember the original indexes of the new samples.<

15条回答
  •  盖世英雄少女心
    2020-11-22 10:12

    For this type of question Store the orignal array data into a new data and then binary search the first element of the sorted array into the duplicated array and that indice should be stored into a vector or array.

    input array=>a
    duplicate array=>b
    vector=>c(Stores the indices(position) of the orignal array
    Syntax:
    for(i=0;i

    Here binarysearch is a function which takes the array,size of array,searching item and would return the position of the searched item

提交回复
热议问题