#include <stdlib.h>
#include <time.h>
#include <iostream>
#include <math.h>
using namespace std;
int get_rand_num()
{
return abs( rand() % 1001 );
}
bool is_exist(int* array,int iFind,int iEnd,int iBegin = 0)
{
for( int i = iBegin; i< iEnd; ++i)
{
if( array[i] == iFind)
{
return true;
}
}
return false;
}
void bubble_sort(int * array,int iEnd,int iBegin = 0)
{
int i,j;
for( i = iEnd-1; i > iBegin; i--)
{
for( j = iBegin;j< i; j++)
{
if( array[j] > array[j+1])
{
swap(array[j],array[j+1]);
}
}
}
}
void swap( int& a,int& b)
{
int temp = a;
a = b;
b = temp;
}
void run()
{
srand(time(NULL));
cout<< "请输入需要产生的数组大小N 0<N<=200" << endl;
int n;
cin >> n;
int * array = new int[n];
int i ;
for( i = 0; i< n;)
{
int x = get_rand_num();
if( is_exist(array,x,i))
{
continue;
}
array[i++] = x;
}
cout << "排序结果如下:" << endl;
for( i = 0; i< n; i++)
{
cout<< array[i] << endl;
}
}
int main(int argc,char*argv[])
{
run();
return 0;
}