C
1 int intcomp( int * x, int * y) 2 { 3 return * x - * y; 4 } 5 6 int a[ 1000000 ]; 7 int main( void ) 8 { 9 int i, n = 0 ; 10 while (scanf( " %d " , & a[n]) != EOF) 11 n ++ ; 12 qsort(a, n, sizeof ( int ), intcomp); 13 for (i = 0 ; i < n; i ++ ) 14 printf( " %d\n " , a[i]); 15 return 0 ; 16 }
1 int main( void ) 2 { 3 set S; 4 int i; 5 set ::iterator j; 6 while (cin >> i) 7 S.insert(i); 8 for (j = S.begin(); j != S.end(); ++ j) 9 cout << * j << " \n " ; 10 return 0 ; 11 }
bit
1 #define BITSPERWORD 32 2 #define SHIFT 5 3 #define MASK 0x1F 4 #define N 10000000 5 int a[ 1 + N / BITSPERWORD]; 6 void set ( int i) { a[i >> SHIFT] |= ( 1 << (i & MASK)); } 7 void clr( int i) { a[i >> SHIFT] &= ~ ( 1 << (i & MASK)); } 8 int test( int i){ return a[i >> SHIFT] & ( 1 << (i & MASK)); }