Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- #include <algorithm>
- #include <math.h>
- #include <stdlib.h>
- using namespace std;
- void INmas(int *m, int a) {//ввод массива с клавиатуры
- cout << "Введите " << a << " чисел: ";
- for (int i = 0; i < a; i++) {
- do {
- cin >> m[i];
- } while (0 < m[i] < 100);
- }
- }
- void INrand(int *m, int a) {//заполнение массива рандомными числами
- for (int i = 0; i < a; i++) {
- m[i] = 1 + rand() % 100;
- }
- }
- void Out(int *m, int a) {//вывод массива на экран
- for (int i = 0; i < a; i++) {
- cout << m[i] << " ";
- }
- }
- int main()
- {
- setlocale(LC_ALL, "Russian");
- int n;
- int otvet;
- do {
- cout << "Введите верхнюю границу массива (не более 1000 элементов): ";
- cin >> n;
- } while (n > 1000);
- int *mas = new int[n];
- do {
- cout << "Как вы хотите заполнить массив? введите 0 - с кавиатуры, введите 1 - автоматически: ";
- cin >> otvet;
- } while (otvet != 0 || otvet != 1);
- if (otvet = 0)
- INmas(mas, n);
- else if(otvet = 1)
- INrand(mas, n);
- Out(mas, n);
- delete[] mas;
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement