/* ECP: FILEname=fig7_11.c */ /* 1*/ #include /* 2*/ #define MaxN 10 /* 3*/ /* Read Up To MaxItems Ints, With No Attempts At Error Recovery */ /* 4*/ int /* 5*/ GetInts( int Array[ ], int MaxItems ) /* 6*/ { /* 7*/ int i = 0; /* 8*/ printf( "Enter up to %d integers: ", MaxItems ); /* 9*/ while( i < MaxItems && scanf( "%d", &Array[ i ] ) == 1 ) /*10*/ i++; /*11*/ return i; /*12*/ } /*13*/ /* Print Non-Duplicates: Sorted Array Array With N Items */ /*14*/ void /*15*/ PrintNondup( const int Array[ ], unsigned int N ) /*16*/ { /*17*/ int i; /*18*/ printf( "%d", Array[ 0 ] ); /*19*/ for( i = 1; i < N; i++ ) /*20*/ if( Array[ i ] != Array[ i - 1 ] ) /*21*/ printf( " %d", Array[ i ] ); /*22*/ printf( "\n" ); /*23*/ } /*24*/ main( void ) /*25*/ { /*26*/ int Num[ MaxN ]; /*27*/ int ItemsRead; /*28*/ ItemsRead = GetInts( Num, MaxN ); /*29*/ printf( "Processing %d items\n", ItemsRead ); /*30*/ if( ItemsRead > 0 ) /*31*/ { /*32*/ InsertSort( Num, ItemsRead ); /*33*/ PrintNondup( Num, ItemsRead ); /*34*/ } /*35*/ return !ItemsRead; /*36*/ }