I am new in C++. This is my program, which is generating a random number from 1 to 270:
#include <iostream>
#include <ctime>
#include <cstdlib>
void myFuncB(int par)
{
std::cout << "unique = " << par; //print the unique number
}
void myFuncA()
{
int parameter = 0;
std::cout << "Random numbers generated between 1 and 270:" << "\n";
for(int i = 0; i < 270; i++)
{
parameter = rand() % 270;
std::cout << "parameter=" << parameter << "\n";
// myFuncB(parameter);
}
}
int main() {
srand(time(0)); // Initialize random number generator.
myFuncA();
return 0;
}
I want myFuncB(int par) to print the unique values only, not repeating any int value.
How can I do this without using a data structure like an array?