#include <algorithm> #include <iostream> using namespace std; int main() { const int MAX = 10; char carr[MAX] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'}; for (int i = 0; i < MAX; i++) cout << carr[i] << " "; cout << endl; // carr+MAX points one position past array bounds random_shuffle(carr, carr+MAX); // display shuffled elements for (int i = 0; i < MAX; i++) cout << carr[i] << " "; cout << endl; }
Hosted by www.Geocities.ws

1