#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#define MAXN 10000000
using namespace std ;
int a[MAXN] , n , nsize , tmp[MAXN] ;
int cmp( const void * _a , const void * _b )
{
int *a = ( int* )_a ;
int *b = ( int* )_b ;
return *a - *b ;
}
void distinct()
nsize = 0 ;
for( int i = 0 ; i < n ; ++i )
if( a[i] != a[i+1] )
tmp[nsize++] = a[i] ;
memcpy( a , tmp , sizeof( int )*nsize ) ;
int main()
cout << "表中元素個數為:(不超過10000000)" << endl ;
cin >> n ;
cin >> a[i] ;
//非遞減排序
qsort( a , n , sizeof( int ) , cmp ) ;
distinct() ;
//輸出去重後的表,10個一行
int cnt = 0 ;
for( int i = 0 ; i < nsize ; ++i )
if( cnt == 10 )
cout << endl ;
cout << a[i] << " ";
return 0 ;
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#define MAXN 10000000
using namespace std ;
int a[MAXN] , n , nsize , tmp[MAXN] ;
int cmp( const void * _a , const void * _b )
{
int *a = ( int* )_a ;
int *b = ( int* )_b ;
return *a - *b ;
}
void distinct()
{
nsize = 0 ;
for( int i = 0 ; i < n ; ++i )
{
if( a[i] != a[i+1] )
{
tmp[nsize++] = a[i] ;
}
}
memcpy( a , tmp , sizeof( int )*nsize ) ;
}
int main()
{
cout << "表中元素個數為:(不超過10000000)" << endl ;
cin >> n ;
for( int i = 0 ; i < n ; ++i )
{
cin >> a[i] ;
}
//非遞減排序
qsort( a , n , sizeof( int ) , cmp ) ;
distinct() ;
//輸出去重後的表,10個一行
int cnt = 0 ;
for( int i = 0 ; i < nsize ; ++i )
{
if( cnt == 10 )
cout << endl ;
cout << a[i] << " ";
}
return 0 ;
}