1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
#include <algorithm>
#include <vector>
#include <iostream>
using namespace std;
int main(){
std::vector<int> MyVector;
for (int i = 0; i < 10; i++)
MyVector.push_back(rand());
std::sort(MyVector.begin(), MyVector.end());
vector<int>::iterator it;
for (it = MyVector.begin(); it < MyVector.end(); ++it)
std::cout << *it << ',';
return 0;
}
|
MyVector now has 10 random values
MyVector now has 10 random values in order (lowest-to-highest)
41,6334,11478,15724,18468,19169,24464,26500,26962,29358 |