用另一个数组下标的形式记录一个一维数组中下标所对应的元素出现在个数,并对此一维数组进行排序。
例如:一个一维数组中的元素为:a[4] = { 2,3,2,5 };此数组为一个长度为4的数组,另一个空数组x[6]={ 0 };x[0] = 0,因为使用下标的形式记录a数组中的元素,此时x[]的下标为0,但a数组中没有0这个元素,所以x[0] = 0;类似,x[1]=0;x[2] = 2,这是因为在a数组中2这个元素出现了2次,同样可知,a[3] = 1,a[4] = 0,a[5] = 1;a数组中的所有元素遍历完,最大的元素为5,所以我们为x申请的空间大小为6,x[6]将不会被取到;
#include<iostream>
using namespace std;
void input(int *p,int n); //input the array value
void disp(int *p, int n); //input the input array value.
void search(int *p,int *x, int m, int n); //according the array's index to sreach element
void output(int *p, int index,