Николай Веселуха
Высший разум
(361134)
4 года назад
#include <iostream>
#include <iomanip>
#include <ctime>
using namespace std;
int main() {
srand(static_cast<unsigned>(time(nullptr)));
cout << ">>> ";
int n;
cin >> n;
int* box = new (nothrow)int[n];
if (box != nullptr) {
for (auto i = 0; i < n; ++i) box[i] = 1 + rand() % 50;
for (auto i = 0; i < n; ++i) cout << setw(4) << box[i];
cout.put('\n');
delete[] box;
box = nullptr;
} else cout << "Not enough memory!\n";
system("pause");
}