home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1997 May
/
Pcwk0597.iso
/
borland
/
cb
/
setup
/
cbuilder
/
data.z
/
RNDSHUFL.CPP
< prev
next >
Wrap
Text File
|
1997-02-28
|
771b
|
32 lines
#include <algorithm>
#include <vector>
using namespace std;
int main ()
{
//
// Initialize a vector with an array of integers.
//
int arr[10] = {1,2,3,4,5,6,7,8,9,10};
vector<int> v(arr+0, arr+10);
//
// Print out elements in original (sorted) order.
//
cout << "Elements before random_shuffle: " << endl << " ";
copy(v.begin(), v.end(), ostream_iterator<int>(cout," "));
cout << endl << endl;
//
// Mix them up with random_shuffle.
//
random_shuffle(v.begin(), v.end());
//
// Print out the mixed up elements.
//
cout << "Elements after random_shuffle: " << endl << " ";
copy(v.begin(), v.end(), ostream_iterator<int>(cout," "));
cout << endl;
return 0;
}