I am try to change the order of an array of char like this :
char arr_char[]="ABCDEFGHIJABCDEFGHIJ";
i used the rand() function in the following code :
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main()
{
char arr_char[]="ABCDEFGHIJABCDEFGHIJ";
int arrSize=sizeof(arr_char)-1;
srand(time(0));
for(int i=0;i<20;i++)
{
cout<<arr_char[rand() % arrSize]<<" ";
}
}
but the rand function repeat some characters more than twice and i want to change the order of the array in which every characters repeat only twice not more .
Aucun commentaire:
Enregistrer un commentaire