#include <iostream>
#include <vector>
#include <cstdlib>
#include <ctime>
#include <random> 

using namespace std;

int main() {
    const int SIZE = 20;
    vector<int> values(SIZE);

    srand(static_cast<unsigned int>(time(0)));

    for (int i = 0; i < SIZE; ++i) {
        values[i] = rand() % 6 + 1;
    }

    for (int i = 0; i < SIZE; ++i) {
        if (i + 1 < SIZE && values[i] == values[i + 1] && (i == 0 || values[i-1] != values[i])) {
             cout << "(";
        }

        cout << " " << values[i];

        if ( (i + 1 == SIZE) || (values[i] != values[i + 1] && (i > 0 && values[i-1] == values[i])) ) {
             cout << ")";
        }
    }

    cout << endl;

    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: