#include "stdafx.h"
#include <string.h>
#include<iostream>
using namespace std;
const int max = 1024;
int main()
{
int a[] = { 1,1,2};
int tmp[max]; //定义模板数组
int length = sizeof(a) / sizeof(int);//定义整型数组a的长度
memset(tmp, 0, max * sizeof(int)); //tmp模板数组元素置零
int i;
for ( i = 0; i<length; ++i) //求数组
{
tmp[a[i]]++;
}
int j = 0;
for (i = 0; i<max; ++i)
{
if (tmp[i] != 0)
{
a[j] = i;
++j;
if (tmp[i]>1)
--length; //长度减去1
}
}
//输出
for (i = 0; i<length; ++i)
{
cout<<a[i]<< " " ;
}
return 0;
}