Untitled

mail@pastecode.io avatar
unknown
c_cpp
a month ago
732 B
3
Indexable
Never
#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;
}
Leave a Comment