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 paremeter = 0;
std::cout << "Random numbers generated between 1 and 270:" << "\n";
for(int i = 0; i < 270; i++)
{
paremeter = rand() % 270;
std::cout << "paremeter=" << paremeter << "\n";
// myFuncB(paremeter);
}
}
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?
Aucun commentaire:
Enregistrer un commentaire