You can use random_shuffle ...
Code:
#include <algorithm>
// after entering the data ...
random_shuffle(g,g+4);
random_shuffle(b,b+4);
random_shuffle(a,a+4);
random_shuffle(l,l+4);
for (int c = 0; c < 4; c++)
{
cout << g[c] << " and " << b[c] << " are " << a[c] << " from a " << l[c] << endl;
}
Also, there is a bug when entering the data. It happens when you use operator >>
followed by getline() [ a google search should describe the problem in detail ].
Between the operator >> and the getline(), use the ignore() function:
Code:
cin >> b[bi];
cin.ignore(10000,'\n');
Bookmarks