Hello
Take this sketch. Try and check it out for your project.
constexpr int SizeOfArray {10};
int randomNumbers[SizeOfArray];
void setup() {
Serial.begin(9600);
randomSeed(analogRead(0));
for (auto &randomNumber : randomNumbers) randomNumber = -1;
int write_ = 0;
do {
int random_ = random(0, SizeOfArray);
bool douple = false;
for (int read_ = 0; read_ < write_ + 1; read_++) if (random_ == randomNumbers[read_]) douple = true;
if (!douple) randomNumbers[write_++] = random_;
} while (!(write_ == SizeOfArray));
for (auto randomNumber : randomNumbers) Serial.print(randomNumber), Serial.print(F(" "));
Serial.println(F(" "));
}
void loop() {
}
Have nice day and enjoy coding in C++.