#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <iterator>
#include <iostream>

int main()
{
    constexpr int MIN = 1 ;
    constexpr int MAX = 50 ;
    constexpr std::size_t SZ = MAX - MIN + 1 ;
    constexpr std::size_t N = 7 ;

    std::srand( std::time(nullptr) ) ;

    // 1. create an array containing numbers 1 to 50
    int a[SZ] ;
    std::iota( std::begin(a), std::end(a), MIN ) ;

    // 2. generate a random permutation of the array
    std::random_shuffle( std::begin(a), std::end(a) ) ;

    // 3. pick the first 7 numbers
    for( std::size_t i = 0 ; i < N ; ++i ) std::cout << a[i] << ' ' ;
    std::cout << '\n' ;
}
