so i have a project, this project is about the random things program. the problem is when I want to create a random team generator, using an array, the printed data is often the same or duplicate. how to solve this problem? is it still possible to use arrays?
#include <iostream>
#include <stdlib.h>
#include <time.h>
using namespace std;
int main() {
int a,b,c,d,e,f,i,random;
string name[100],g;
srand(time(0));
cout<<"enter the number of members : ";
cin>>a;
cout<<"enter the number of members per group : ";
cin>>b;
c = a / b;
cout<<"The number of groups is: "<< c <<endl;
for(e=0;e<a;e++){
cout<< "Enter the Member's name of-" << e+1 << ": ";
cin>> name[e];
}
for(d=0;d<c;d++){
cout<<"Team"<< d+1<<endl;
for(f=1;f<=b;f++){
random = rand()%a;
cout<< random[name]<<endl;
}
}
}
Aucun commentaire:
Enregistrer un commentaire