Отсортировать элементы в массиве случайным образом — C++(Си)

#include <iostream>
#include <algorithm>
 
int main ()
{
    const int size=10;
    int MAS[size]={1,2,3,4,5,6,7,8,9,10};
    std::cout << "Before:\n";
    for (int i=0; i<size; i++)
        std::cout << " " << MAS[i];
    std::cout << std::endl;
 
    std::random_shuffle (MAS, MAS+size);
 
    std::cout << "After:\n";
    for (int i=0; i<size; i++)
        std::cout << " " << MAS[i];
    std::cout << std::endl;
 
    system ("pause");
    return 0;
}

Leave a Comment