Untitled
unknown
c_cpp
a year ago
732 B
5
Indexable
#include <stdio.h> void showUnique( unsigned int n, int array[] ) { int temp[ n ] = {}; temp[ 0 ] = array[ 0 ]; printf( "%d\n", array[ 0 ] ); for( int i = 1; i < n; ++i ) { int isUnique = 1; for( int j = 0; j < i; ++j ) { if( temp[ j ] == array[ i ] ) { isUnique = 0; break; } } if( isUnique ) { temp[ i ] = array[ i ]; printf( "%d\n", array[ i ] ); } } } int main() { int array[] = { 5, 4, -3, 5, 4 }; int arraySize = sizeof( array ) / sizeof( array[ 0 ] ); showUnique( arraySize, array ); return 0; }
Editor is loading...
Leave a Comment