Код программы:
#include "iostream"
#include "list"
#include "iterator"
using namespace std;
void show (list <int> l) {
int i=-1;
list<int>::iterator it;
for (it = l.begin(); it != l.end(); ++it) {
i++;
if (i % 4 == 0)cout << endl;
cout << *it << " ";
}
}
void make_l (list <int> l,int n) {
for (int i = 0; i < n; i++) {
l.push_back(rand()%100+0);
}
}
int main()
{
setlocale(LC_ALL, "ru");
list<int> listok;
int n;
cout << "Введите количество переменных в лист: ";
cin >> n;
make_l(listok, n);
show(listok);
cout << "Отсортированный лист: \n";
listok.sort();
show(listok);
return 0;
}