输入 :5,7,9,-6,0,77,900,6
输出:2,4,5,0,1,6,7,3

解决方案 »

  1.   

    输出的是原num所在数组升序排序后的Index
      

  2.   

    int[] a = new int[]{5,7,9,-6,0,77,900,6};
    int[] b = new int[]{5,7,9,-6,0,77,900,6};
    Arrays.sort(b);
    for(int i=0; i<a.length; i++) {
        while(a[i] != b[j++]) {
        }
        System.out.print(j + "\t");    
    }
    伪代码咯,呵呵
      

  3.   


    int[] a = new int[]{5,7,9,-6,0,77,900,6};
    int[] b = new int[]{5,7,9,-6,0,77,900,6};
    java.util.Arrays.sort(b);
    for(int i=0; i<a.length; i++) {
        int j=0;
        while(a[i] != b[j]) {
            j++;
        }
        System.out.print(j + "\t");
    }大意了,更正一下,(~ o ~)~zZ
      

  4.   


    #include <iostream>
    #include <vector>
    #include <algorithm>
    using namespace std;
    int main()
    {
    int array[] = {5, 7, 9, -6, 0, 77, 900, 6};
    size_t array_size = sizeof(array)/sizeof(int);
    vector<int> ivec(array, array + array_size);

    sort(ivec.begin(), ivec.end());

    for(int i=0; i<array_size; ++i){
    cout<<(find(ivec.begin(), ivec.end(), array[i]) - ivec.begin())<<" ";
    }
    cout<<endl;

    return 0;
    }