0
I need to create a function that is in a file. h that generates random numbers n (defined by the user and passed by parameter in the function), and populate set b with the generated values.
tConj.cpp file
TConj a,b,c,d;
int elemento, i,op;
long unsigned num;
if (op==6){
int num;
printf("Quantidade de elementos a ser gerado: ");
scanf("%d",&num);
b = GerarConjunto(num);
}
tconj file. h
struct TConj{
int * elemento;
int n;
};
TConj GerarConjunto(int n){
TConj vet;
vet.elemento = (int *) malloc(10*sizeof(int));
int var;
for (int i=0;i<n;i++){
srand(time(NULL));
var = rand()%n;
vet.elemento[i] = var;
}
return vet;
}
To ask a question it is necessary to say what problem you are having, and what you have already tried to do. Waiting for people to have crystal ball to know what you want, or what’s wrong just looking at your program isn’t good tone.
– jsbueno
I found the C tag strange in this question, considering that your program has Cpp extension, besides the fact that you are talking about vectors.
– Nexus